<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

<title>class ActiveRecord::Base - Rails Framework Documentation</title>

<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
</script>

<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="../index.html">Home</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/mysql2_adapter.rb
    <li>/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb
    <li>/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/sqlite3_adapter.rb
    <li>/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/mysql_adapter.rb
    <li>/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb
    <li>/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link"><a href="../Object.html">Object</a>
  
</nav>

    <!-- Included Modules -->
<nav id="includes-section" class="section">
  <h3 class="section-header">Included Modules</h3>

  <ul class="link-list">
  
  
    <li><a class="include" href="Persistence.html">ActiveRecord::Persistence</a>
  
  
  
    <li><a class="include" href="ReadonlyAttributes.html">ActiveRecord::ReadonlyAttributes</a>
  
  
  
    <li><a class="include" href="ModelSchema.html">ActiveRecord::ModelSchema</a>
  
  
  
    <li><a class="include" href="Inheritance.html">ActiveRecord::Inheritance</a>
  
  
  
    <li><a class="include" href="Scoping.html">ActiveRecord::Scoping</a>
  
  
  
    <li><a class="include" href="Sanitization.html">ActiveRecord::Sanitization</a>
  
  
  
    <li><a class="include" href="AttributeAssignment.html">ActiveRecord::AttributeAssignment</a>
  
  
  
    <li><a class="include" href="../ActiveModel/Conversion.html">ActiveModel::Conversion</a>
  
  
  
    <li><a class="include" href="Integration.html">ActiveRecord::Integration</a>
  
  
  
    <li><a class="include" href="Validations.html">ActiveRecord::Validations</a>
  
  
  
    <li><a class="include" href="Locking/Optimistic.html">ActiveRecord::Locking::Optimistic</a>
  
  
  
    <li><a class="include" href="Locking/Pessimistic.html">ActiveRecord::Locking::Pessimistic</a>
  
  
  
    <li><a class="include" href="AttributeMethods.html">ActiveRecord::AttributeMethods</a>
  
  
  
    <li><a class="include" href="Callbacks.html">ActiveRecord::Callbacks</a>
  
  
  
    <li><a class="include" href="../ActiveModel/Observing.html">ActiveModel::Observing</a>
  
  
  
    <li><a class="include" href="Timestamp.html">ActiveRecord::Timestamp</a>
  
  
  
    <li><a class="include" href="Associations.html">ActiveRecord::Associations</a>
  
  
  
    <li><a class="include" href="IdentityMap.html">ActiveRecord::IdentityMap</a>
  
  
  
    <li><a class="include" href="../ActiveModel/SecurePassword.html">ActiveModel::SecurePassword</a>
  
  
  
    <li><a class="include" href="AutosaveAssociation.html">ActiveRecord::AutosaveAssociation</a>
  
  
  
    <li><a class="include" href="NestedAttributes.html">ActiveRecord::NestedAttributes</a>
  
  
  
    <li><a class="include" href="Aggregations.html">ActiveRecord::Aggregations</a>
  
  
  
    <li><a class="include" href="Transactions.html">ActiveRecord::Transactions</a>
  
  
  
    <li><a class="include" href="Reflection.html">ActiveRecord::Reflection</a>
  
  
  
    <li><a class="include" href="AttributeMethods/Serialization.html">ActiveRecord::AttributeMethods::Serialization</a>
  
  
  
    <li><a class="include" href="Store.html">ActiveRecord::Store</a>
  
  
  </ul>
</nav>

    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-c-3D-3D-3D">::===</a>
    
    <li><a href="#method-c-arel_engine">::arel_engine</a>
    
    <li><a href="#method-c-arel_table">::arel_table</a>
    
    <li><a href="#method-c-clear_active_connections-21">::clear_active_connections!</a>
    
    <li><a href="#method-c-configurations">::configurations</a>
    
    <li><a href="#method-c-connected-3F">::connected?</a>
    
    <li><a href="#method-c-connection">::connection</a>
    
    <li><a href="#method-c-connection_config">::connection_config</a>
    
    <li><a href="#method-c-connection_handler">::connection_handler</a>
    
    <li><a href="#method-c-connection_id">::connection_id</a>
    
    <li><a href="#method-c-connection_id-3D">::connection_id=</a>
    
    <li><a href="#method-c-connection_pool">::connection_pool</a>
    
    <li><a href="#method-c-default_timezone">::default_timezone</a>
    
    <li><a href="#method-c-establish_connection">::establish_connection</a>
    
    <li><a href="#method-c-generated_feature_methods">::generated_feature_methods</a>
    
    <li><a href="#method-c-inspect">::inspect</a>
    
    <li><a href="#method-c-logger">::logger</a>
    
    <li><a href="#method-c-mysql2_connection">::mysql2_connection</a>
    
    <li><a href="#method-c-new">::new</a>
    
    <li><a href="#method-c-remove_connection">::remove_connection</a>
    
    <li><a href="#method-c-retrieve_connection">::retrieve_connection</a>
    
    <li><a href="#method-c-schema_format">::schema_format</a>
    
    <li><a href="#method-c-timestamped_migrations">::timestamped_migrations</a>
    
    <li><a href="#method-i-3C-3D-3E">#&lt;=&gt;</a>
    
    <li><a href="#method-i-3D-3D">#==</a>
    
    <li><a href="#method-i-connection">#connection</a>
    
    <li><a href="#method-i-encode_with">#encode_with</a>
    
    <li><a href="#method-i-eql-3F">#eql?</a>
    
    <li><a href="#method-i-freeze">#freeze</a>
    
    <li><a href="#method-i-frozen-3F">#frozen?</a>
    
    <li><a href="#method-i-hash">#hash</a>
    
    <li><a href="#method-i-init_with">#init_with</a>
    
    <li><a href="#method-i-initialize_dup">#initialize_dup</a>
    
    <li><a href="#method-i-inspect">#inspect</a>
    
    <li><a href="#method-i-readonly-21">#readonly!</a>
    
    <li><a href="#method-i-readonly-3F">#readonly?</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/actionmailer-3_2_7/MIT-LICENSE.html">MIT-LICENSE</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/actionmailer-3_2_7/README_rdoc.html">README</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/actionpack-3_2_7/MIT-LICENSE.html">MIT-LICENSE</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/actionpack-3_2_7/README_rdoc.html">README</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/activemodel-3_2_7/MIT-LICENSE.html">MIT-LICENSE</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/activemodel-3_2_7/README_rdoc.html">README</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/activerecord-3_2_7/README_rdoc.html">README</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/activeresource-3_2_7/README_rdoc.html">README</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/activesupport-3_2_7/README_rdoc.html">README</a>
  
    <li class="file"><a href="..//usr/local/lib/ruby/gems/1_9_1/gems/railties-3_2_7/README_rdoc.html">README</a>
  
    <li class="file"><a href="../README_rdoc.html">README</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="../ActiveRecord.html">ActiveRecord</a>
  
    <li><a href="../ActiveRecord/ActiveRecordError.html">ActiveRecord::ActiveRecordError</a>
  
    <li><a href="../ActiveRecord/AdapterNotFound.html">ActiveRecord::AdapterNotFound</a>
  
    <li><a href="../ActiveRecord/AdapterNotSpecified.html">ActiveRecord::AdapterNotSpecified</a>
  
    <li><a href="../ActiveRecord/Aggregations.html">ActiveRecord::Aggregations</a>
  
    <li><a href="../ActiveRecord/Aggregations/ClassMethods.html">ActiveRecord::Aggregations::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AssociationTypeMismatch.html">ActiveRecord::AssociationTypeMismatch</a>
  
    <li><a href="../ActiveRecord/Associations.html">ActiveRecord::Associations</a>
  
    <li><a href="../ActiveRecord/Associations/ClassMethods.html">ActiveRecord::Associations::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeAssignment.html">ActiveRecord::AttributeAssignment</a>
  
    <li><a href="../ActiveRecord/AttributeAssignment/ClassMethods.html">ActiveRecord::AttributeAssignment::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeAssignmentError.html">ActiveRecord::AttributeAssignmentError</a>
  
    <li><a href="../ActiveRecord/AttributeMethods.html">ActiveRecord::AttributeMethods</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/BeforeTypeCast.html">ActiveRecord::AttributeMethods::BeforeTypeCast</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/ClassMethods.html">ActiveRecord::AttributeMethods::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/DeprecatedUnderscoreRead.html">ActiveRecord::AttributeMethods::DeprecatedUnderscoreRead</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/DeprecatedUnderscoreRead/ClassMethods.html">ActiveRecord::AttributeMethods::DeprecatedUnderscoreRead::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Dirty.html">ActiveRecord::AttributeMethods::Dirty</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/PrimaryKey.html">ActiveRecord::AttributeMethods::PrimaryKey</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/PrimaryKey/ClassMethods.html">ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Query.html">ActiveRecord::AttributeMethods::Query</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Read.html">ActiveRecord::AttributeMethods::Read</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Read/ClassMethods.html">ActiveRecord::AttributeMethods::Read::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Serialization.html">ActiveRecord::AttributeMethods::Serialization</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Serialization/Attribute.html">ActiveRecord::AttributeMethods::Serialization::Attribute</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Serialization/ClassMethods.html">ActiveRecord::AttributeMethods::Serialization::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/TimeZoneConversion.html">ActiveRecord::AttributeMethods::TimeZoneConversion</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/TimeZoneConversion/ClassMethods.html">ActiveRecord::AttributeMethods::TimeZoneConversion::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Write.html">ActiveRecord::AttributeMethods::Write</a>
  
    <li><a href="../ActiveRecord/AttributeMethods/Write/ClassMethods.html">ActiveRecord::AttributeMethods::Write::ClassMethods</a>
  
    <li><a href="../ActiveRecord/AutosaveAssociation.html">ActiveRecord::AutosaveAssociation</a>
  
    <li><a href="../ActiveRecord/AutosaveAssociation/ClassMethods.html">ActiveRecord::AutosaveAssociation::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Base.html">ActiveRecord::Base</a>
  
    <li><a href="../ActiveRecord/Batches.html">ActiveRecord::Batches</a>
  
    <li><a href="../ActiveRecord/Calculations.html">ActiveRecord::Calculations</a>
  
    <li><a href="../ActiveRecord/Callbacks.html">ActiveRecord::Callbacks</a>
  
    <li><a href="../ActiveRecord/ConfigurationError.html">ActiveRecord::ConfigurationError</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/AbstractAdapter.html">ActiveRecord::ConnectionAdapters::AbstractAdapter</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/AbstractMysqlAdapter.html">ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/ConnectionHandler.html">ActiveRecord::ConnectionAdapters::ConnectionHandler</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/ConnectionManagement.html">ActiveRecord::ConnectionAdapters::ConnectionManagement</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/ConnectionPool.html">ActiveRecord::ConnectionAdapters::ConnectionPool</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/DatabaseLimits.html">ActiveRecord::ConnectionAdapters::DatabaseLimits</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/DatabaseStatements.html">ActiveRecord::ConnectionAdapters::DatabaseStatements</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/Mysql2Adapter.html">ActiveRecord::ConnectionAdapters::Mysql2Adapter</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/MysqlAdapter.html">ActiveRecord::ConnectionAdapters::MysqlAdapter</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/MysqlAdapter/StatementPool.html">ActiveRecord::ConnectionAdapters::MysqlAdapter::StatementPool</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/PostgreSQLAdapter.html">ActiveRecord::ConnectionAdapters::PostgreSQLAdapter</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/PostgreSQLAdapter/StatementPool.html">ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::StatementPool</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/PostgreSQLAdapter/TableDefinition.html">ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/PostgreSQLAdapter/Utils.html">ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::Utils</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/PostgreSQLColumn.html">ActiveRecord::ConnectionAdapters::PostgreSQLColumn</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/QueryCache.html">ActiveRecord::ConnectionAdapters::QueryCache</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/Quoting.html">ActiveRecord::ConnectionAdapters::Quoting</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/SQLiteAdapter.html">ActiveRecord::ConnectionAdapters::SQLiteAdapter</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/SQLiteAdapter/ExplainPrettyPrinter.html">ActiveRecord::ConnectionAdapters::SQLiteAdapter::ExplainPrettyPrinter</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/SQLiteAdapter/StatementPool.html">ActiveRecord::ConnectionAdapters::SQLiteAdapter::StatementPool</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/SQLiteAdapter/Version.html">ActiveRecord::ConnectionAdapters::SQLiteAdapter::Version</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/SchemaCache.html">ActiveRecord::ConnectionAdapters::SchemaCache</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/SchemaStatements.html">ActiveRecord::ConnectionAdapters::SchemaStatements</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/StatementPool.html">ActiveRecord::ConnectionAdapters::StatementPool</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/Table.html">ActiveRecord::ConnectionAdapters::Table</a>
  
    <li><a href="../ActiveRecord/ConnectionAdapters/TableDefinition.html">ActiveRecord::ConnectionAdapters::TableDefinition</a>
  
    <li><a href="../ActiveRecord/ConnectionNotEstablished.html">ActiveRecord::ConnectionNotEstablished</a>
  
    <li><a href="../ActiveRecord/ConnectionTimeoutError.html">ActiveRecord::ConnectionTimeoutError</a>
  
    <li><a href="../ActiveRecord/CounterCache.html">ActiveRecord::CounterCache</a>
  
    <li><a href="../ActiveRecord/DangerousAttributeError.html">ActiveRecord::DangerousAttributeError</a>
  
    <li><a href="../ActiveRecord/Delegation.html">ActiveRecord::Delegation</a>
  
    <li><a href="../ActiveRecord/DynamicFinderMatch.html">ActiveRecord::DynamicFinderMatch</a>
  
    <li><a href="../ActiveRecord/DynamicMatchers.html">ActiveRecord::DynamicMatchers</a>
  
    <li><a href="../ActiveRecord/DynamicScopeMatch.html">ActiveRecord::DynamicScopeMatch</a>
  
    <li><a href="../ActiveRecord/Explain.html">ActiveRecord::Explain</a>
  
    <li><a href="../ActiveRecord/FinderMethods.html">ActiveRecord::FinderMethods</a>
  
    <li><a href="../ActiveRecord/Fixtures.html">ActiveRecord::Fixtures</a>
  
    <li><a href="../ActiveRecord/Fixtures/File.html">ActiveRecord::Fixtures::File</a>
  
    <li><a href="../ActiveRecord/IdentityMap.html">ActiveRecord::IdentityMap</a>
  
    <li><a href="../ActiveRecord/IdentityMap/Middleware.html">ActiveRecord::IdentityMap::Middleware</a>
  
    <li><a href="../ActiveRecord/Inheritance.html">ActiveRecord::Inheritance</a>
  
    <li><a href="../ActiveRecord/Inheritance/ClassMethods.html">ActiveRecord::Inheritance::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Integration.html">ActiveRecord::Integration</a>
  
    <li><a href="../ActiveRecord/InvalidForeignKey.html">ActiveRecord::InvalidForeignKey</a>
  
    <li><a href="../ActiveRecord/IrreversibleMigration.html">ActiveRecord::IrreversibleMigration</a>
  
    <li><a href="../ActiveRecord/Locking.html">ActiveRecord::Locking</a>
  
    <li><a href="../ActiveRecord/Locking/Optimistic.html">ActiveRecord::Locking::Optimistic</a>
  
    <li><a href="../ActiveRecord/Locking/Optimistic/ClassMethods.html">ActiveRecord::Locking::Optimistic::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Locking/Pessimistic.html">ActiveRecord::Locking::Pessimistic</a>
  
    <li><a href="../ActiveRecord/LogSubscriber.html">ActiveRecord::LogSubscriber</a>
  
    <li><a href="../ActiveRecord/Migration.html">ActiveRecord::Migration</a>
  
    <li><a href="../ActiveRecord/Migration/CommandRecorder.html">ActiveRecord::Migration::CommandRecorder</a>
  
    <li><a href="../ActiveRecord/MigrationProxy.html">ActiveRecord::MigrationProxy</a>
  
    <li><a href="../ActiveRecord/ModelSchema.html">ActiveRecord::ModelSchema</a>
  
    <li><a href="../ActiveRecord/ModelSchema/ClassMethods.html">ActiveRecord::ModelSchema::ClassMethods</a>
  
    <li><a href="../ActiveRecord/MultiparameterAssignmentErrors.html">ActiveRecord::MultiparameterAssignmentErrors</a>
  
    <li><a href="../ActiveRecord/NestedAttributes.html">ActiveRecord::NestedAttributes</a>
  
    <li><a href="../ActiveRecord/NestedAttributes/ClassMethods.html">ActiveRecord::NestedAttributes::ClassMethods</a>
  
    <li><a href="../ActiveRecord/NestedAttributes/TooManyRecords.html">ActiveRecord::NestedAttributes::TooManyRecords</a>
  
    <li><a href="../ActiveRecord/Observer.html">ActiveRecord::Observer</a>
  
    <li><a href="../ActiveRecord/Persistence.html">ActiveRecord::Persistence</a>
  
    <li><a href="../ActiveRecord/Persistence/ClassMethods.html">ActiveRecord::Persistence::ClassMethods</a>
  
    <li><a href="../ActiveRecord/PreparedStatementInvalid.html">ActiveRecord::PreparedStatementInvalid</a>
  
    <li><a href="../ActiveRecord/QueryCache.html">ActiveRecord::QueryCache</a>
  
    <li><a href="../ActiveRecord/QueryCache/ClassMethods.html">ActiveRecord::QueryCache::ClassMethods</a>
  
    <li><a href="../ActiveRecord/QueryMethods.html">ActiveRecord::QueryMethods</a>
  
    <li><a href="../ActiveRecord/Querying.html">ActiveRecord::Querying</a>
  
    <li><a href="../ActiveRecord/Railtie.html">ActiveRecord::Railtie</a>
  
    <li><a href="../ActiveRecord/Railties.html">ActiveRecord::Railties</a>
  
    <li><a href="../ActiveRecord/Railties/ControllerRuntime.html">ActiveRecord::Railties::ControllerRuntime</a>
  
    <li><a href="../ActiveRecord/Railties/ControllerRuntime/ClassMethods.html">ActiveRecord::Railties::ControllerRuntime::ClassMethods</a>
  
    <li><a href="../ActiveRecord/ReadOnlyRecord.html">ActiveRecord::ReadOnlyRecord</a>
  
    <li><a href="../ActiveRecord/ReadonlyAttributes.html">ActiveRecord::ReadonlyAttributes</a>
  
    <li><a href="../ActiveRecord/ReadonlyAttributes/ClassMethods.html">ActiveRecord::ReadonlyAttributes::ClassMethods</a>
  
    <li><a href="../ActiveRecord/RecordInvalid.html">ActiveRecord::RecordInvalid</a>
  
    <li><a href="../ActiveRecord/RecordNotFound.html">ActiveRecord::RecordNotFound</a>
  
    <li><a href="../ActiveRecord/RecordNotSaved.html">ActiveRecord::RecordNotSaved</a>
  
    <li><a href="../ActiveRecord/RecordNotUnique.html">ActiveRecord::RecordNotUnique</a>
  
    <li><a href="../ActiveRecord/Reflection.html">ActiveRecord::Reflection</a>
  
    <li><a href="../ActiveRecord/Reflection/ClassMethods.html">ActiveRecord::Reflection::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Reflection/MacroReflection.html">ActiveRecord::Reflection::MacroReflection</a>
  
    <li><a href="../ActiveRecord/Relation.html">ActiveRecord::Relation</a>
  
    <li><a href="../ActiveRecord/Result.html">ActiveRecord::Result</a>
  
    <li><a href="../ActiveRecord/Rollback.html">ActiveRecord::Rollback</a>
  
    <li><a href="../ActiveRecord/Sanitization.html">ActiveRecord::Sanitization</a>
  
    <li><a href="../ActiveRecord/Sanitization/ClassMethods.html">ActiveRecord::Sanitization::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Schema.html">ActiveRecord::Schema</a>
  
    <li><a href="../ActiveRecord/Scoping.html">ActiveRecord::Scoping</a>
  
    <li><a href="../ActiveRecord/Scoping/ClassMethods.html">ActiveRecord::Scoping::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Scoping/Default.html">ActiveRecord::Scoping::Default</a>
  
    <li><a href="../ActiveRecord/Scoping/Default/ClassMethods.html">ActiveRecord::Scoping::Default::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Scoping/Named.html">ActiveRecord::Scoping::Named</a>
  
    <li><a href="../ActiveRecord/Scoping/Named/ClassMethods.html">ActiveRecord::Scoping::Named::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Serialization.html">ActiveRecord::Serialization</a>
  
    <li><a href="../ActiveRecord/SerializationTypeMismatch.html">ActiveRecord::SerializationTypeMismatch</a>
  
    <li><a href="../ActiveRecord/SessionStore.html">ActiveRecord::SessionStore</a>
  
    <li><a href="../ActiveRecord/SessionStore/Session.html">ActiveRecord::SessionStore::Session</a>
  
    <li><a href="../ActiveRecord/SessionStore/SqlBypass.html">ActiveRecord::SessionStore::SqlBypass</a>
  
    <li><a href="../ActiveRecord/SpawnMethods.html">ActiveRecord::SpawnMethods</a>
  
    <li><a href="../ActiveRecord/StaleObjectError.html">ActiveRecord::StaleObjectError</a>
  
    <li><a href="../ActiveRecord/StatementInvalid.html">ActiveRecord::StatementInvalid</a>
  
    <li><a href="../ActiveRecord/Store.html">ActiveRecord::Store</a>
  
    <li><a href="../ActiveRecord/Store/ClassMethods.html">ActiveRecord::Store::ClassMethods</a>
  
    <li><a href="../ActiveRecord/TestFixtures.html">ActiveRecord::TestFixtures</a>
  
    <li><a href="../ActiveRecord/TestFixtures/ClassMethods.html">ActiveRecord::TestFixtures::ClassMethods</a>
  
    <li><a href="../ActiveRecord/ThrowResult.html">ActiveRecord::ThrowResult</a>
  
    <li><a href="../ActiveRecord/Timestamp.html">ActiveRecord::Timestamp</a>
  
    <li><a href="../ActiveRecord/Transactions.html">ActiveRecord::Transactions</a>
  
    <li><a href="../ActiveRecord/Transactions/ClassMethods.html">ActiveRecord::Transactions::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Translation.html">ActiveRecord::Translation</a>
  
    <li><a href="../ActiveRecord/UnknownAttributeError.html">ActiveRecord::UnknownAttributeError</a>
  
    <li><a href="../ActiveRecord/UnknownPrimaryKey.html">ActiveRecord::UnknownPrimaryKey</a>
  
    <li><a href="../ActiveRecord/Validations.html">ActiveRecord::Validations</a>
  
    <li><a href="../ActiveRecord/Validations/AssociatedValidator.html">ActiveRecord::Validations::AssociatedValidator</a>
  
    <li><a href="../ActiveRecord/Validations/ClassMethods.html">ActiveRecord::Validations::ClassMethods</a>
  
    <li><a href="../ActiveRecord/Validations/UniquenessValidator.html">ActiveRecord::Validations::UniquenessValidator</a>
  
    <li><a href="../ActiveRecord/WrappedDatabaseException.html">ActiveRecord::WrappedDatabaseException</a>
  
    <li><a href="../ActiveSupport.html">ActiveSupport</a>
  
    <li><a href="../ActiveSupport/Autoload.html">ActiveSupport::Autoload</a>
  
    <li><a href="../ActiveSupport/BacktraceCleaner.html">ActiveSupport::BacktraceCleaner</a>
  
    <li><a href="../ActiveSupport/Base64.html">ActiveSupport::Base64</a>
  
    <li><a href="../ActiveSupport/BasicObject.html">ActiveSupport::BasicObject</a>
  
    <li><a href="../ActiveSupport/Benchmarkable.html">ActiveSupport::Benchmarkable</a>
  
    <li><a href="../ActiveSupport/BufferedLogger.html">ActiveSupport::BufferedLogger</a>
  
    <li><a href="../ActiveSupport/BufferedLogger/Severity.html">ActiveSupport::BufferedLogger::Severity</a>
  
    <li><a href="../ActiveSupport/Cache.html">ActiveSupport::Cache</a>
  
    <li><a href="../ActiveSupport/Cache/Entry.html">ActiveSupport::Cache::Entry</a>
  
    <li><a href="../ActiveSupport/Cache/FileStore.html">ActiveSupport::Cache::FileStore</a>
  
    <li><a href="../ActiveSupport/Cache/MemCacheStore.html">ActiveSupport::Cache::MemCacheStore</a>
  
    <li><a href="../ActiveSupport/Cache/MemoryStore.html">ActiveSupport::Cache::MemoryStore</a>
  
    <li><a href="../ActiveSupport/Cache/NullStore.html">ActiveSupport::Cache::NullStore</a>
  
    <li><a href="../ActiveSupport/Cache/Store.html">ActiveSupport::Cache::Store</a>
  
    <li><a href="../ActiveSupport/Cache/Strategy.html">ActiveSupport::Cache::Strategy</a>
  
    <li><a href="../ActiveSupport/Cache/Strategy/LocalCache.html">ActiveSupport::Cache::Strategy::LocalCache</a>
  
    <li><a href="../ActiveSupport/Cache/Strategy/LocalCache/LocalStore.html">ActiveSupport::Cache::Strategy::LocalCache::LocalStore</a>
  
    <li><a href="../ActiveSupport/Callbacks.html">ActiveSupport::Callbacks</a>
  
    <li><a href="../ActiveSupport/Callbacks/ClassMethods.html">ActiveSupport::Callbacks::ClassMethods</a>
  
    <li><a href="../ActiveSupport/Concern.html">ActiveSupport::Concern</a>
  
    <li><a href="../ActiveSupport/Configurable.html">ActiveSupport::Configurable</a>
  
    <li><a href="../ActiveSupport/Configurable/ClassMethods.html">ActiveSupport::Configurable::ClassMethods</a>
  
    <li><a href="../ActiveSupport/Configurable/Configuration.html">ActiveSupport::Configurable::Configuration</a>
  
    <li><a href="../ActiveSupport/Dependencies.html">ActiveSupport::Dependencies</a>
  
    <li><a href="../ActiveSupport/Dependencies/ClassCache.html">ActiveSupport::Dependencies::ClassCache</a>
  
    <li><a href="../ActiveSupport/Dependencies/WatchStack.html">ActiveSupport::Dependencies::WatchStack</a>
  
    <li><a href="../ActiveSupport/Deprecation.html">ActiveSupport::Deprecation</a>
  
    <li><a href="../ActiveSupport/DescendantsTracker.html">ActiveSupport::DescendantsTracker</a>
  
    <li><a href="../ActiveSupport/Duration.html">ActiveSupport::Duration</a>
  
    <li><a href="../ActiveSupport/FileUpdateChecker.html">ActiveSupport::FileUpdateChecker</a>
  
    <li><a href="../ActiveSupport/FileWatcher.html">ActiveSupport::FileWatcher</a>
  
    <li><a href="../ActiveSupport/FileWatcher/Backend.html">ActiveSupport::FileWatcher::Backend</a>
  
    <li><a href="../ActiveSupport/Gzip.html">ActiveSupport::Gzip</a>
  
    <li><a href="../ActiveSupport/Gzip/Stream.html">ActiveSupport::Gzip::Stream</a>
  
    <li><a href="../ActiveSupport/HashWithIndifferentAccess.html">ActiveSupport::HashWithIndifferentAccess</a>
  
    <li><a href="../ActiveSupport/HashWithIndifferentAccess.html">ActiveSupport::HashWithIndifferentAccess</a>
  
    <li><a href="../ActiveSupport/Inflector.html">ActiveSupport::Inflector</a>
  
    <li><a href="../ActiveSupport/Inflector/Inflections.html">ActiveSupport::Inflector::Inflections</a>
  
    <li><a href="../ActiveSupport/InheritableOptions.html">ActiveSupport::InheritableOptions</a>
  
    <li><a href="../ActiveSupport/JSON.html">ActiveSupport::JSON</a>
  
    <li><a href="../ActiveSupport/JSON/Encoding.html">ActiveSupport::JSON::Encoding</a>
  
    <li><a href="../ActiveSupport/JSON/Encoding/CircularReferenceError.html">ActiveSupport::JSON::Encoding::CircularReferenceError</a>
  
    <li><a href="../ActiveSupport/JSON/Encoding/Encoder.html">ActiveSupport::JSON::Encoding::Encoder</a>
  
    <li><a href="../ActiveSupport/JSON/Variable.html">ActiveSupport::JSON::Variable</a>
  
    <li><a href="../ActiveSupport/LogSubscriber.html">ActiveSupport::LogSubscriber</a>
  
    <li><a href="../ActiveSupport/LogSubscriber/TestHelper.html">ActiveSupport::LogSubscriber::TestHelper</a>
  
    <li><a href="../ActiveSupport/LogSubscriber/TestHelper/MockLogger.html">ActiveSupport::LogSubscriber::TestHelper::MockLogger</a>
  
    <li><a href="../ActiveSupport/Memoizable.html">ActiveSupport::Memoizable</a>
  
    <li><a href="../ActiveSupport/Memoizable/InstanceMethods.html">ActiveSupport::Memoizable::InstanceMethods</a>
  
    <li><a href="../ActiveSupport/MessageEncryptor.html">ActiveSupport::MessageEncryptor</a>
  
    <li><a href="../ActiveSupport/MessageEncryptor/InvalidMessage.html">ActiveSupport::MessageEncryptor::InvalidMessage</a>
  
    <li><a href="../ActiveSupport/MessageVerifier.html">ActiveSupport::MessageVerifier</a>
  
    <li><a href="../ActiveSupport/MessageVerifier/InvalidSignature.html">ActiveSupport::MessageVerifier::InvalidSignature</a>
  
    <li><a href="../ActiveSupport/Multibyte.html">ActiveSupport::Multibyte</a>
  
    <li><a href="../ActiveSupport/Multibyte/Chars.html">ActiveSupport::Multibyte::Chars</a>
  
    <li><a href="../ActiveSupport/Multibyte/EncodingError.html">ActiveSupport::Multibyte::EncodingError</a>
  
    <li><a href="../ActiveSupport/Multibyte/Unicode.html">ActiveSupport::Multibyte::Unicode</a>
  
    <li><a href="../ActiveSupport/Multibyte/Unicode/Codepoint.html">ActiveSupport::Multibyte::Unicode::Codepoint</a>
  
    <li><a href="../ActiveSupport/Multibyte/Unicode/UnicodeDatabase.html">ActiveSupport::Multibyte::Unicode::UnicodeDatabase</a>
  
    <li><a href="../ActiveSupport/Notifications.html">ActiveSupport::Notifications</a>
  
    <li><a href="../ActiveSupport/Notifications/Event.html">ActiveSupport::Notifications::Event</a>
  
    <li><a href="../ActiveSupport/Notifications/Fanout.html">ActiveSupport::Notifications::Fanout</a>
  
    <li><a href="../ActiveSupport/Notifications/Instrumenter.html">ActiveSupport::Notifications::Instrumenter</a>
  
    <li><a href="../ActiveSupport/OrderedHash.html">ActiveSupport::OrderedHash</a>
  
    <li><a href="../ActiveSupport/OrderedOptions.html">ActiveSupport::OrderedOptions</a>
  
    <li><a href="../ActiveSupport/Railtie.html">ActiveSupport::Railtie</a>
  
    <li><a href="../ActiveSupport/Rescuable.html">ActiveSupport::Rescuable</a>
  
    <li><a href="../ActiveSupport/Rescuable/ClassMethods.html">ActiveSupport::Rescuable::ClassMethods</a>
  
    <li><a href="../ActiveSupport/SafeBuffer.html">ActiveSupport::SafeBuffer</a>
  
    <li><a href="../ActiveSupport/SafeBuffer/SafeConcatError.html">ActiveSupport::SafeBuffer::SafeConcatError</a>
  
    <li><a href="../ActiveSupport/StringInquirer.html">ActiveSupport::StringInquirer</a>
  
    <li><a href="../ActiveSupport/TaggedLogging.html">ActiveSupport::TaggedLogging</a>
  
    <li><a href="../ActiveSupport/TestCase.html">ActiveSupport::TestCase</a>
  
    <li><a href="../ActiveSupport/Testing.html">ActiveSupport::Testing</a>
  
    <li><a href="../ActiveSupport/Testing/Assertions.html">ActiveSupport::Testing::Assertions</a>
  
    <li><a href="../ActiveSupport/Testing/Declarative.html">ActiveSupport::Testing::Declarative</a>
  
    <li><a href="../ActiveSupport/Testing/Isolation.html">ActiveSupport::Testing::Isolation</a>
  
    <li><a href="../ActiveSupport/Testing/Isolation/Forking.html">ActiveSupport::Testing::Isolation::Forking</a>
  
    <li><a href="../ActiveSupport/Testing/Isolation/MiniTest.html">ActiveSupport::Testing::Isolation::MiniTest</a>
  
    <li><a href="../ActiveSupport/Testing/Isolation/Subprocess.html">ActiveSupport::Testing::Isolation::Subprocess</a>
  
    <li><a href="../ActiveSupport/Testing/Isolation/TestUnit.html">ActiveSupport::Testing::Isolation::TestUnit</a>
  
    <li><a href="../ActiveSupport/Testing/Pending.html">ActiveSupport::Testing::Pending</a>
  
    <li><a href="../ActiveSupport/Testing/Performance.html">ActiveSupport::Testing::Performance</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Benchmarker.html">ActiveSupport::Testing::Performance::Benchmarker</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/ForClassicTestUnit.html">ActiveSupport::Testing::Performance::ForClassicTestUnit</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/ForMiniTest.html">ActiveSupport::Testing::Performance::ForMiniTest</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics.html">ActiveSupport::Testing::Performance::Metrics</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/Amount.html">ActiveSupport::Testing::Performance::Metrics::Amount</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/Base.html">ActiveSupport::Testing::Performance::Metrics::Base</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/CpuTime.html">ActiveSupport::Testing::Performance::Metrics::CpuTime</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/DigitalInformationUnit.html">ActiveSupport::Testing::Performance::Metrics::DigitalInformationUnit</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/GcRuns.html">ActiveSupport::Testing::Performance::Metrics::GcRuns</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/GcTime.html">ActiveSupport::Testing::Performance::Metrics::GcTime</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/Memory.html">ActiveSupport::Testing::Performance::Metrics::Memory</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/Objects.html">ActiveSupport::Testing::Performance::Metrics::Objects</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/ProcessTime.html">ActiveSupport::Testing::Performance::Metrics::ProcessTime</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/Time.html">ActiveSupport::Testing::Performance::Metrics::Time</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/UserTime.html">ActiveSupport::Testing::Performance::Metrics::UserTime</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Metrics/WallTime.html">ActiveSupport::Testing::Performance::Metrics::WallTime</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Performer.html">ActiveSupport::Testing::Performance::Performer</a>
  
    <li><a href="../ActiveSupport/Testing/Performance/Profiler.html">ActiveSupport::Testing::Performance::Profiler</a>
  
    <li><a href="../ActiveSupport/Testing/ProxyTestResult.html">ActiveSupport::Testing::ProxyTestResult</a>
  
    <li><a href="../ActiveSupport/Testing/RemoteError.html">ActiveSupport::Testing::RemoteError</a>
  
    <li><a href="../ActiveSupport/Testing/SetupAndTeardown.html">ActiveSupport::Testing::SetupAndTeardown</a>
  
    <li><a href="../ActiveSupport/Testing/SetupAndTeardown/ClassMethods.html">ActiveSupport::Testing::SetupAndTeardown::ClassMethods</a>
  
    <li><a href="../ActiveSupport/Testing/SetupAndTeardown/ForClassicTestUnit.html">ActiveSupport::Testing::SetupAndTeardown::ForClassicTestUnit</a>
  
    <li><a href="../ActiveSupport/Testing/SetupAndTeardown/ForMiniTest.html">ActiveSupport::Testing::SetupAndTeardown::ForMiniTest</a>
  
    <li><a href="../ActiveSupport/TimeWithZone.html">ActiveSupport::TimeWithZone</a>
  
    <li><a href="../ActiveSupport/TimeZone.html">ActiveSupport::TimeZone</a>
  
    <li><a href="../ActiveSupport/XmlMini.html">ActiveSupport::XmlMini</a>
  
    <li><a href="../ActiveSupport/XmlMini_LibXMLSAX.html">ActiveSupport::XmlMini_LibXMLSAX</a>
  
    <li><a href="../ActiveSupport/XmlMini_LibXMLSAX/HashBuilder.html">ActiveSupport::XmlMini_LibXMLSAX::HashBuilder</a>
  
    <li><a href="../ActiveSupport/XmlMini_NokogiriSAX.html">ActiveSupport::XmlMini_NokogiriSAX</a>
  
    <li><a href="../ActiveSupport/XmlMini_NokogiriSAX/HashBuilder.html">ActiveSupport::XmlMini_NokogiriSAX::HashBuilder</a>
  
    <li><a href="../ActionController.html">ActionController</a>
  
    <li><a href="../ActionController/Base.html">ActionController::Base</a>
  
    <li><a href="../ActionController/Caching.html">ActionController::Caching</a>
  
    <li><a href="../ActionController/Caching/Actions.html">ActionController::Caching::Actions</a>
  
    <li><a href="../ActionController/Caching/Actions/ActionCachePath.html">ActionController::Caching::Actions::ActionCachePath</a>
  
    <li><a href="../ActionController/Caching/Actions/ClassMethods.html">ActionController::Caching::Actions::ClassMethods</a>
  
    <li><a href="../ActionController/Caching/ConfigMethods.html">ActionController::Caching::ConfigMethods</a>
  
    <li><a href="../ActionController/Caching/Fragments.html">ActionController::Caching::Fragments</a>
  
    <li><a href="../ActionController/Caching/Pages.html">ActionController::Caching::Pages</a>
  
    <li><a href="../ActionController/Caching/Pages/ClassMethods.html">ActionController::Caching::Pages::ClassMethods</a>
  
    <li><a href="../ActionController/Caching/Sweeping.html">ActionController::Caching::Sweeping</a>
  
    <li><a href="../ActionController/Compatibility.html">ActionController::Compatibility</a>
  
    <li><a href="../ActionController/ConditionalGet.html">ActionController::ConditionalGet</a>
  
    <li><a href="../ActionController/Cookies.html">ActionController::Cookies</a>
  
    <li><a href="../ActionController/DataStreaming.html">ActionController::DataStreaming</a>
  
    <li><a href="../ActionController/Flash.html">ActionController::Flash</a>
  
    <li><a href="../ActionController/ForceSSL.html">ActionController::ForceSSL</a>
  
    <li><a href="../ActionController/ForceSSL/ClassMethods.html">ActionController::ForceSSL::ClassMethods</a>
  
    <li><a href="../ActionController/Head.html">ActionController::Head</a>
  
    <li><a href="../ActionController/Helpers.html">ActionController::Helpers</a>
  
    <li><a href="../ActionController/Helpers/ClassMethods.html">ActionController::Helpers::ClassMethods</a>
  
    <li><a href="../ActionController/HideActions.html">ActionController::HideActions</a>
  
    <li><a href="../ActionController/HideActions/ClassMethods.html">ActionController::HideActions::ClassMethods</a>
  
    <li><a href="../ActionController/HttpAuthentication.html">ActionController::HttpAuthentication</a>
  
    <li><a href="../ActionController/HttpAuthentication/Basic.html">ActionController::HttpAuthentication::Basic</a>
  
    <li><a href="../ActionController/HttpAuthentication/Basic/ControllerMethods.html">ActionController::HttpAuthentication::Basic::ControllerMethods</a>
  
    <li><a href="../ActionController/HttpAuthentication/Basic/ControllerMethods/ClassMethods.html">ActionController::HttpAuthentication::Basic::ControllerMethods::ClassMethods</a>
  
    <li><a href="../ActionController/HttpAuthentication/Digest.html">ActionController::HttpAuthentication::Digest</a>
  
    <li><a href="../ActionController/HttpAuthentication/Digest/ControllerMethods.html">ActionController::HttpAuthentication::Digest::ControllerMethods</a>
  
    <li><a href="../ActionController/HttpAuthentication/Token.html">ActionController::HttpAuthentication::Token</a>
  
    <li><a href="../ActionController/HttpAuthentication/Token/ControllerMethods.html">ActionController::HttpAuthentication::Token::ControllerMethods</a>
  
    <li><a href="../ActionController/ImplicitRender.html">ActionController::ImplicitRender</a>
  
    <li><a href="../ActionController/Instrumentation.html">ActionController::Instrumentation</a>
  
    <li><a href="../ActionController/Instrumentation/ClassMethods.html">ActionController::Instrumentation::ClassMethods</a>
  
    <li><a href="../ActionController/LogSubscriber.html">ActionController::LogSubscriber</a>
  
    <li><a href="../ActionController/Metal.html">ActionController::Metal</a>
  
    <li><a href="../ActionController/Middleware.html">ActionController::Middleware</a>
  
    <li><a href="../ActionController/Middleware/ActionMiddleware.html">ActionController::Middleware::ActionMiddleware</a>
  
    <li><a href="../ActionController/MimeResponds.html">ActionController::MimeResponds</a>
  
    <li><a href="../ActionController/MimeResponds/ClassMethods.html">ActionController::MimeResponds::ClassMethods</a>
  
    <li><a href="../ActionController/ParamsWrapper.html">ActionController::ParamsWrapper</a>
  
    <li><a href="../ActionController/ParamsWrapper/ClassMethods.html">ActionController::ParamsWrapper::ClassMethods</a>
  
    <li><a href="../ActionController/RackDelegation.html">ActionController::RackDelegation</a>
  
    <li><a href="../ActionController/Railtie.html">ActionController::Railtie</a>
  
    <li><a href="../ActionController/Railties.html">ActionController::Railties</a>
  
    <li><a href="../ActionController/Railties/Paths.html">ActionController::Railties::Paths</a>
  
    <li><a href="../ActionController/RecordIdentifier.html">ActionController::RecordIdentifier</a>
  
    <li><a href="../ActionController/Redirecting.html">ActionController::Redirecting</a>
  
    <li><a href="../ActionController/Renderers.html">ActionController::Renderers</a>
  
    <li><a href="../ActionController/Renderers/All.html">ActionController::Renderers::All</a>
  
    <li><a href="../ActionController/Renderers/ClassMethods.html">ActionController::Renderers::ClassMethods</a>
  
    <li><a href="../ActionController/Rendering.html">ActionController::Rendering</a>
  
    <li><a href="../ActionController/RequestForgeryProtection.html">ActionController::RequestForgeryProtection</a>
  
    <li><a href="../ActionController/RequestForgeryProtection/ClassMethods.html">ActionController::RequestForgeryProtection::ClassMethods</a>
  
    <li><a href="../ActionController/Rescue.html">ActionController::Rescue</a>
  
    <li><a href="../ActionController/Responder.html">ActionController::Responder</a>
  
    <li><a href="../ActionController/SessionManagement.html">ActionController::SessionManagement</a>
  
    <li><a href="../ActionController/SessionManagement/ClassMethods.html">ActionController::SessionManagement::ClassMethods</a>
  
    <li><a href="../ActionController/Streaming.html">ActionController::Streaming</a>
  
    <li><a href="../ActionController/TemplateAssertions.html">ActionController::TemplateAssertions</a>
  
    <li><a href="../ActionController/TestCase.html">ActionController::TestCase</a>
  
    <li><a href="../ActionController/TestCase/Behavior.html">ActionController::TestCase::Behavior</a>
  
    <li><a href="../ActionController/TestCase/Behavior/ClassMethods.html">ActionController::TestCase::Behavior::ClassMethods</a>
  
    <li><a href="../ActionController/TestCase/RaiseActionExceptions.html">ActionController::TestCase::RaiseActionExceptions</a>
  
    <li><a href="../ActionController/TestResponse.html">ActionController::TestResponse</a>
  
    <li><a href="../ActionController/Testing.html">ActionController::Testing</a>
  
    <li><a href="../ActionController/Testing/ClassMethods.html">ActionController::Testing::ClassMethods</a>
  
    <li><a href="../ActionController/UrlFor.html">ActionController::UrlFor</a>
  
    <li><a href="../ActionView.html">ActionView</a>
  
    <li><a href="../ActionView/ActionView.html">ActionView::ActionView</a>
  
    <li><a href="../ActionView/ActionView/ActionView.html">ActionView::ActionView::ActionView</a>
  
    <li><a href="../ActionView/ActionView/ActionView/Base.html">ActionView::ActionView::ActionView::Base</a>
  
    <li><a href="../ActionView/Base.html">ActionView::Base</a>
  
    <li><a href="../ActionView/Context.html">ActionView::Context</a>
  
    <li><a href="../ActionView/FileSystemResolver.html">ActionView::FileSystemResolver</a>
  
    <li><a href="../ActionView/FixtureResolver.html">ActionView::FixtureResolver</a>
  
    <li><a href="../ActionView/Helpers.html">ActionView::Helpers</a>
  
    <li><a href="../ActionView/Helpers/ActiveModelHelper.html">ActionView::Helpers::ActiveModelHelper</a>
  
    <li><a href="../ActionView/Helpers/ActiveModelInstanceTag.html">ActionView::Helpers::ActiveModelInstanceTag</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper.html">ActionView::Helpers::AssetTagHelper</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper/AssetIncludeTag.html">ActionView::Helpers::AssetTagHelper::AssetIncludeTag</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper/JavascriptIncludeTag.html">ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper/JavascriptTagHelpers.html">ActionView::Helpers::AssetTagHelper::JavascriptTagHelpers</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper/JavascriptTagHelpers/ClassMethods.html">ActionView::Helpers::AssetTagHelper::JavascriptTagHelpers::ClassMethods</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper/StylesheetIncludeTag.html">ActionView::Helpers::AssetTagHelper::StylesheetIncludeTag</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper/StylesheetTagHelpers.html">ActionView::Helpers::AssetTagHelper::StylesheetTagHelpers</a>
  
    <li><a href="../ActionView/Helpers/AssetTagHelper/StylesheetTagHelpers/ClassMethods.html">ActionView::Helpers::AssetTagHelper::StylesheetTagHelpers::ClassMethods</a>
  
    <li><a href="../ActionView/Helpers/AtomFeedHelper.html">ActionView::Helpers::AtomFeedHelper</a>
  
    <li><a href="../ActionView/Helpers/AtomFeedHelper/AtomBuilder.html">ActionView::Helpers::AtomFeedHelper::AtomBuilder</a>
  
    <li><a href="../ActionView/Helpers/AtomFeedHelper/AtomFeedBuilder.html">ActionView::Helpers::AtomFeedHelper::AtomFeedBuilder</a>
  
    <li><a href="../ActionView/Helpers/CacheHelper.html">ActionView::Helpers::CacheHelper</a>
  
    <li><a href="../ActionView/Helpers/CaptureHelper.html">ActionView::Helpers::CaptureHelper</a>
  
    <li><a href="../ActionView/Helpers/CsrfHelper.html">ActionView::Helpers::CsrfHelper</a>
  
    <li><a href="../ActionView/Helpers/DateHelper.html">ActionView::Helpers::DateHelper</a>
  
    <li><a href="../ActionView/Helpers/DateHelperInstanceTag.html">ActionView::Helpers::DateHelperInstanceTag</a>
  
    <li><a href="../ActionView/Helpers/DebugHelper.html">ActionView::Helpers::DebugHelper</a>
  
    <li><a href="../ActionView/Helpers/FormBuilder.html">ActionView::Helpers::FormBuilder</a>
  
    <li><a href="../ActionView/Helpers/FormHelper.html">ActionView::Helpers::FormHelper</a>
  
    <li><a href="../ActionView/Helpers/FormOptionsHelper.html">ActionView::Helpers::FormOptionsHelper</a>
  
    <li><a href="../ActionView/Helpers/FormTagHelper.html">ActionView::Helpers::FormTagHelper</a>
  
    <li><a href="../ActionView/Helpers/InstanceTag.html">ActionView::Helpers::InstanceTag</a>
  
    <li><a href="../ActionView/Helpers/JavaScriptHelper.html">ActionView::Helpers::JavaScriptHelper</a>
  
    <li><a href="../ActionView/Helpers/NumberHelper.html">ActionView::Helpers::NumberHelper</a>
  
    <li><a href="../ActionView/Helpers/NumberHelper/InvalidNumberError.html">ActionView::Helpers::NumberHelper::InvalidNumberError</a>
  
    <li><a href="../ActionView/Helpers/OutputSafetyHelper.html">ActionView::Helpers::OutputSafetyHelper</a>
  
    <li><a href="../ActionView/Helpers/RecordTagHelper.html">ActionView::Helpers::RecordTagHelper</a>
  
    <li><a href="../ActionView/Helpers/RenderingHelper.html">ActionView::Helpers::RenderingHelper</a>
  
    <li><a href="../ActionView/Helpers/SanitizeHelper.html">ActionView::Helpers::SanitizeHelper</a>
  
    <li><a href="../ActionView/Helpers/TagHelper.html">ActionView::Helpers::TagHelper</a>
  
    <li><a href="../ActionView/Helpers/TextHelper.html">ActionView::Helpers::TextHelper</a>
  
    <li><a href="../ActionView/Helpers/TranslationHelper.html">ActionView::Helpers::TranslationHelper</a>
  
    <li><a href="../ActionView/Helpers/UrlHelper.html">ActionView::Helpers::UrlHelper</a>
  
    <li><a href="../ActionView/LogSubscriber.html">ActionView::LogSubscriber</a>
  
    <li><a href="../ActionView/LookupContext.html">ActionView::LookupContext</a>
  
    <li><a href="../ActionView/LookupContext/DetailsCache.html">ActionView::LookupContext::DetailsCache</a>
  
    <li><a href="../ActionView/LookupContext/ViewPaths.html">ActionView::LookupContext::ViewPaths</a>
  
    <li><a href="../ActionView/NullResolver.html">ActionView::NullResolver</a>
  
    <li><a href="../ActionView/PartialRenderer.html">ActionView::PartialRenderer</a>
  
    <li><a href="../ActionView/Railtie.html">ActionView::Railtie</a>
  
    <li><a href="../ActionView/Renderer.html">ActionView::Renderer</a>
  
    <li><a href="../ActionView/Resolver.html">ActionView::Resolver</a>
  
    <li><a href="../ActionView/Resolver/Path.html">ActionView::Resolver::Path</a>
  
    <li><a href="../ActionView/Template.html">ActionView::Template</a>
  
    <li><a href="../ActionView/Template/Handlers.html">ActionView::Template::Handlers</a>
  
    <li><a href="../ActionView/Template/Handlers/Builder.html">ActionView::Template::Handlers::Builder</a>
  
    <li><a href="../ActionView/Template/Handlers/ERB.html">ActionView::Template::Handlers::ERB</a>
  
    <li><a href="../ActionView/Template/Handlers/Erubis.html">ActionView::Template::Handlers::Erubis</a>
  
    <li><a href="../ActionView/TestCase.html">ActionView::TestCase</a>
  
    <li><a href="../ActionView/TestCase/Behavior.html">ActionView::TestCase::Behavior</a>
  
    <li><a href="../ActionView/TestCase/Behavior/ClassMethods.html">ActionView::TestCase::Behavior::ClassMethods</a>
  
    <li><a href="../ActionView/TestCase/Behavior/Locals.html">ActionView::TestCase::Behavior::Locals</a>
  
    <li><a href="../ActionView/TestCase/TestController.html">ActionView::TestCase::TestController</a>
  
    <li><a href="../ActiveModel.html">ActiveModel</a>
  
    <li><a href="../ActiveModel/AttributeMethods.html">ActiveModel::AttributeMethods</a>
  
    <li><a href="../ActiveModel/AttributeMethods/ClassMethods.html">ActiveModel::AttributeMethods::ClassMethods</a>
  
    <li><a href="../ActiveModel/AttributeMethods/ClassMethods/AttributeMethodMatcher.html">ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher</a>
  
    <li><a href="../ActiveModel/BlockValidator.html">ActiveModel::BlockValidator</a>
  
    <li><a href="../ActiveModel/Callbacks.html">ActiveModel::Callbacks</a>
  
    <li><a href="../ActiveModel/Conversion.html">ActiveModel::Conversion</a>
  
    <li><a href="../ActiveModel/Dirty.html">ActiveModel::Dirty</a>
  
    <li><a href="../ActiveModel/EachValidator.html">ActiveModel::EachValidator</a>
  
    <li><a href="../ActiveModel/Errors.html">ActiveModel::Errors</a>
  
    <li><a href="../ActiveModel/Lint.html">ActiveModel::Lint</a>
  
    <li><a href="../ActiveModel/Lint/Tests.html">ActiveModel::Lint::Tests</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity.html">ActiveModel::MassAssignmentSecurity</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/BlackList.html">ActiveModel::MassAssignmentSecurity::BlackList</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/ClassMethods.html">ActiveModel::MassAssignmentSecurity::ClassMethods</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/Error.html">ActiveModel::MassAssignmentSecurity::Error</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/LoggerSanitizer.html">ActiveModel::MassAssignmentSecurity::LoggerSanitizer</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/PermissionSet.html">ActiveModel::MassAssignmentSecurity::PermissionSet</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/Sanitizer.html">ActiveModel::MassAssignmentSecurity::Sanitizer</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/StrictSanitizer.html">ActiveModel::MassAssignmentSecurity::StrictSanitizer</a>
  
    <li><a href="../ActiveModel/MassAssignmentSecurity/WhiteList.html">ActiveModel::MassAssignmentSecurity::WhiteList</a>
  
    <li><a href="../ActiveModel/MissingAttributeError.html">ActiveModel::MissingAttributeError</a>
  
    <li><a href="../ActiveModel/Name.html">ActiveModel::Name</a>
  
    <li><a href="../ActiveModel/Naming.html">ActiveModel::Naming</a>
  
    <li><a href="../ActiveModel/Observer.html">ActiveModel::Observer</a>
  
    <li><a href="../ActiveModel/ObserverArray.html">ActiveModel::ObserverArray</a>
  
    <li><a href="../ActiveModel/Observing.html">ActiveModel::Observing</a>
  
    <li><a href="../ActiveModel/Observing/ClassMethods.html">ActiveModel::Observing::ClassMethods</a>
  
    <li><a href="../ActiveModel/SecurePassword.html">ActiveModel::SecurePassword</a>
  
    <li><a href="../ActiveModel/SecurePassword/ClassMethods.html">ActiveModel::SecurePassword::ClassMethods</a>
  
    <li><a href="../ActiveModel/SecurePassword/InstanceMethodsOnActivation.html">ActiveModel::SecurePassword::InstanceMethodsOnActivation</a>
  
    <li><a href="../ActiveModel/Serialization.html">ActiveModel::Serialization</a>
  
    <li><a href="../ActiveModel/Serializers.html">ActiveModel::Serializers</a>
  
    <li><a href="../ActiveModel/Serializers/JSON.html">ActiveModel::Serializers::JSON</a>
  
    <li><a href="../ActiveModel/Serializers/Xml.html">ActiveModel::Serializers::Xml</a>
  
    <li><a href="../ActiveModel/StrictValidationFailed.html">ActiveModel::StrictValidationFailed</a>
  
    <li><a href="../ActiveModel/Translation.html">ActiveModel::Translation</a>
  
    <li><a href="../ActiveModel/Validations.html">ActiveModel::Validations</a>
  
    <li><a href="../ActiveModel/Validations/AcceptanceValidator.html">ActiveModel::Validations::AcceptanceValidator</a>
  
    <li><a href="../ActiveModel/Validations/Callbacks.html">ActiveModel::Validations::Callbacks</a>
  
    <li><a href="../ActiveModel/Validations/Callbacks/ClassMethods.html">ActiveModel::Validations::Callbacks::ClassMethods</a>
  
    <li><a href="../ActiveModel/Validations/ClassMethods.html">ActiveModel::Validations::ClassMethods</a>
  
    <li><a href="../ActiveModel/Validations/ConfirmationValidator.html">ActiveModel::Validations::ConfirmationValidator</a>
  
    <li><a href="../ActiveModel/Validations/ExclusionValidator.html">ActiveModel::Validations::ExclusionValidator</a>
  
    <li><a href="../ActiveModel/Validations/FormatValidator.html">ActiveModel::Validations::FormatValidator</a>
  
    <li><a href="../ActiveModel/Validations/HelperMethods.html">ActiveModel::Validations::HelperMethods</a>
  
    <li><a href="../ActiveModel/Validations/InclusionValidator.html">ActiveModel::Validations::InclusionValidator</a>
  
    <li><a href="../ActiveModel/Validations/LengthValidator.html">ActiveModel::Validations::LengthValidator</a>
  
    <li><a href="../ActiveModel/Validations/NumericalityValidator.html">ActiveModel::Validations::NumericalityValidator</a>
  
    <li><a href="../ActiveModel/Validations/PresenceValidator.html">ActiveModel::Validations::PresenceValidator</a>
  
    <li><a href="../ActiveModel/Validations/WithValidator.html">ActiveModel::Validations::WithValidator</a>
  
    <li><a href="../ActiveModel/Validator.html">ActiveModel::Validator</a>
  
    <li><a href="../ActiveResource.html">ActiveResource</a>
  
    <li><a href="../ActiveResource/Base.html">ActiveResource::Base</a>
  
    <li><a href="../ActiveResource/Connection.html">ActiveResource::Connection</a>
  
    <li><a href="../ActiveResource/CustomMethods.html">ActiveResource::CustomMethods</a>
  
    <li><a href="../ActiveResource/CustomMethods/ClassMethods.html">ActiveResource::CustomMethods::ClassMethods</a>
  
    <li><a href="../ActiveResource/Errors.html">ActiveResource::Errors</a>
  
    <li><a href="../ActiveResource/Formats.html">ActiveResource::Formats</a>
  
    <li><a href="../ActiveResource/Formats/JsonFormat.html">ActiveResource::Formats::JsonFormat</a>
  
    <li><a href="../ActiveResource/Formats/XmlFormat.html">ActiveResource::Formats::XmlFormat</a>
  
    <li><a href="../ActiveResource/HttpMock.html">ActiveResource::HttpMock</a>
  
    <li><a href="../ActiveResource/InvalidRequestError.html">ActiveResource::InvalidRequestError</a>
  
    <li><a href="../ActiveResource/LogSubscriber.html">ActiveResource::LogSubscriber</a>
  
    <li><a href="../ActiveResource/Observing.html">ActiveResource::Observing</a>
  
    <li><a href="../ActiveResource/Railtie.html">ActiveResource::Railtie</a>
  
    <li><a href="../ActiveResource/Request.html">ActiveResource::Request</a>
  
    <li><a href="../ActiveResource/Response.html">ActiveResource::Response</a>
  
    <li><a href="../ActiveResource/SSLError.html">ActiveResource::SSLError</a>
  
    <li><a href="../ActiveResource/TimeoutError.html">ActiveResource::TimeoutError</a>
  
    <li><a href="../ActiveResource/Validations.html">ActiveResource::Validations</a>
  
    <li><a href="../HTML.html">HTML</a>
  
    <li><a href="../HTML/FullSanitizer.html">HTML::FullSanitizer</a>
  
    <li><a href="../HTML/LinkSanitizer.html">HTML::LinkSanitizer</a>
  
    <li><a href="../HTML/Sanitizer.html">HTML::Sanitizer</a>
  
    <li><a href="../HTML/Selector.html">HTML::Selector</a>
  
    <li><a href="../HTML/Tag.html">HTML::Tag</a>
  
    <li><a href="../HTML/WhiteListSanitizer.html">HTML::WhiteListSanitizer</a>
  
    <li><a href="../Mysql.html">Mysql</a>
  
    <li><a href="../Mysql/Result.html">Mysql::Result</a>
  
    <li><a href="../Mysql/Stmt.html">Mysql::Stmt</a>
  
    <li><a href="../Mysql/Time.html">Mysql::Time</a>
  
    <li><a href="../Test.html">Test</a>
  
    <li><a href="../Test/Unit.html">Test::Unit</a>
  
    <li><a href="../Test/Unit/Collector.html">Test::Unit::Collector</a>
  
    <li><a href="../Test/Unit/Collector/ObjectSpace.html">Test::Unit::Collector::ObjectSpace</a>
  
    <li><a href="../I18n.html">I18n</a>
  
    <li><a href="../I18n/ExceptionHandler.html">I18n::ExceptionHandler</a>
  
    <li><a href="../I18n/Railtie.html">I18n::Railtie</a>
  
    <li><a href="../Object.html">Object</a>
  
    <li><a href="../ActiveSupport/HashWithIndifferentAccess.html">Object::HashWithIndifferentAccess</a>
  
    <li><a href="../LoadError.html">Object::MissingSourceFile</a>
  
    <li><a href="../ActionMailer.html">ActionMailer</a>
  
    <li><a href="../ActionMailer/Base.html">ActionMailer::Base</a>
  
    <li><a href="../ArJdbcMySQL.html">ArJdbcMySQL</a>
  
    <li><a href="../ArJdbcMySQL/Error.html">ArJdbcMySQL::Error</a>
  
    <li><a href="../ERB.html">ERB</a>
  
    <li><a href="../ERB/Util.html">ERB::Util</a>
  
    <li><a href="../LoadError.html">LoadError</a>
  
    <li><a href="../LoadError.html">LoadError</a>
  
    <li><a href="../Logger.html">Logger</a>
  
    <li><a href="../Logger/SimpleFormatter.html">Logger::SimpleFormatter</a>
  
    <li><a href="../Array.html">Array</a>
  
    <li><a href="../Base64.html">Base64</a>
  
    <li><a href="../Benchmark.html">Benchmark</a>
  
    <li><a href="../BigDecimal.html">BigDecimal</a>
  
    <li><a href="../Class.html">Class</a>
  
    <li><a href="../Date.html">Date</a>
  
    <li><a href="../DateTime.html">DateTime</a>
  
    <li><a href="../Enumerable.html">Enumerable</a>
  
    <li><a href="../FalseClass.html">FalseClass</a>
  
    <li><a href="../File.html">File</a>
  
    <li><a href="../Float.html">Float</a>
  
    <li><a href="../Hash.html">Hash</a>
  
    <li><a href="../Integer.html">Integer</a>
  
    <li><a href="../Kernel.html">Kernel</a>
  
    <li><a href="../Module.html">Module</a>
  
    <li><a href="../NameError.html">NameError</a>
  
    <li><a href="../NilClass.html">NilClass</a>
  
    <li><a href="../Numeric.html">Numeric</a>
  
    <li><a href="../Process.html">Process</a>
  
    <li><a href="../QualifiedConstUtils.html">QualifiedConstUtils</a>
  
    <li><a href="../Rails.html">Rails</a>
  
    <li><a href="../Range.html">Range</a>
  
    <li><a href="../Regexp.html">Regexp</a>
  
    <li><a href="../String.html">String</a>
  
    <li><a href="../Symbol.html">Symbol</a>
  
    <li><a href="../Time.html">Time</a>
  
    <li><a href="../TrueClass.html">TrueClass</a>
  
    <li><a href="../URI.html">URI</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class ActiveRecord::Base</h1>

  <div id="description" class="description">
    
<h1 id="label-Active+Record">Active Record</h1>

<p>Active Record objects don’t specify their attributes directly, but rather
infer them from the table definition with which they’re linked. Adding,
removing, and changing attributes and their type is done directly in the
database. Any change is instantly reflected in the Active Record objects.
The mapping that binds a given Active Record class to a certain database
table will happen automatically in most common cases, but can be
overwritten for the uncommon ones.</p>

<p>See the mapping rules in table_name and the full example in <a
href="../files/activerecord/README_rdoc.html">files/activerecord/README_rdoc.html</a>
for more insight.</p>

<h2 id="label-Creation">Creation</h2>

<p>Active Records accept constructor parameters either in a hash or as a
block. The hash method is especially useful when you’re receiving the data
from somewhere else, like an HTTP request. It works like this:</p>

<pre class="ruby"><span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;David&quot;</span>, :<span class="ruby-identifier">occupation</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;Code Artist&quot;</span>)
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span> <span class="ruby-comment"># =&gt; &quot;David&quot;</span>
</pre>

<p>You can also use block initialization:</p>

<pre class="ruby"><span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">u</span>.<span class="ruby-identifier">name</span> = <span class="ruby-string">&quot;David&quot;</span>
  <span class="ruby-identifier">u</span>.<span class="ruby-identifier">occupation</span> = <span class="ruby-string">&quot;Code Artist&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

<p>And of course you can just create a bare object and specify the attributes
after the fact:</p>

<pre>user = User.new
user.name = &quot;David&quot;
user.occupation = &quot;Code Artist&quot;</pre>

<h2 id="label-Conditions">Conditions</h2>

<p>Conditions can either be specified as a string, array, or hash representing
the WHERE-part of an SQL statement. The array form is to be used when the
condition input is tainted and requires sanitization. The string form can
be used for statements that don’t involve tainted data. The hash form works
much like the array form, except only equality and range is possible.
Examples:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">User</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">authenticate_unsafely</span>(<span class="ruby-identifier">user_name</span>, <span class="ruby-identifier">password</span>)
    <span class="ruby-identifier">where</span>(<span class="ruby-node">&quot;user_name = '#{user_name}' AND password = '#{password}'&quot;</span>).<span class="ruby-identifier">first</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">authenticate_safely</span>(<span class="ruby-identifier">user_name</span>, <span class="ruby-identifier">password</span>)
    <span class="ruby-identifier">where</span>(<span class="ruby-string">&quot;user_name = ? AND password = ?&quot;</span>, <span class="ruby-identifier">user_name</span>, <span class="ruby-identifier">password</span>).<span class="ruby-identifier">first</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">authenticate_safely_simply</span>(<span class="ruby-identifier">user_name</span>, <span class="ruby-identifier">password</span>)
    <span class="ruby-identifier">where</span>(:<span class="ruby-identifier">user_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">user_name</span>, :<span class="ruby-identifier">password</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">password</span>).<span class="ruby-identifier">first</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>The <code>authenticate_unsafely</code> method inserts the parameters
directly into the query and is thus susceptible to SQL-injection attacks if
the <code>user_name</code> and <code>password</code> parameters come
directly from an HTTP request. The <code>authenticate_safely</code> and
<code>authenticate_safely_simply</code> both will sanitize the
<code>user_name</code> and <code>password</code> before inserting them in
the query, which will ensure that an attacker can’t escape the query and
fake the login (or worse).</p>

<p>When using multiple parameters in the conditions, it can easily become hard
to read exactly what the fourth or fifth question mark is supposed to
represent. In those cases, you can resort to named bind variables instead.
That’s done by replacing the question marks with symbols and supplying a
hash with values for the matching symbol keys:</p>

<pre class="ruby"><span class="ruby-constant">Company</span>.<span class="ruby-identifier">where</span>(
  <span class="ruby-string">&quot;id = :id AND name = :name AND division = :division AND created_at &gt; :accounting_date&quot;</span>,
  { :<span class="ruby-identifier">id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">3</span>, :<span class="ruby-identifier">name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;37signals&quot;</span>, :<span class="ruby-identifier">division</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;First&quot;</span>, :<span class="ruby-identifier">accounting_date</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'2005-01-01'</span> }
).<span class="ruby-identifier">first</span>
</pre>

<p>Similarly, a simple hash without a statement will generate conditions based
on equality with the SQL AND operator. For instance:</p>

<pre class="ruby"><span class="ruby-constant">Student</span>.<span class="ruby-identifier">where</span>(:<span class="ruby-identifier">first_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;Harvey&quot;</span>, :<span class="ruby-identifier">status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>)
<span class="ruby-constant">Student</span>.<span class="ruby-identifier">where</span>(<span class="ruby-identifier">params</span>[:<span class="ruby-identifier">student</span>])
</pre>

<p>A range may be used in the hash to use the SQL BETWEEN operator:</p>

<pre class="ruby"><span class="ruby-constant">Student</span>.<span class="ruby-identifier">where</span>(:<span class="ruby-identifier">grade</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">9</span><span class="ruby-operator">..</span><span class="ruby-value">12</span>)
</pre>

<p>An array may be used in the hash to use the SQL IN operator:</p>

<pre class="ruby"><span class="ruby-constant">Student</span>.<span class="ruby-identifier">where</span>(:<span class="ruby-identifier">grade</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">9</span>,<span class="ruby-value">11</span>,<span class="ruby-value">12</span>])
</pre>

<p>When joining tables, nested hashes or keys written in the form
‘table_name.column_name’ can be used to qualify the table name of a
particular condition. For instance:</p>

<pre class="ruby"><span class="ruby-constant">Student</span>.<span class="ruby-identifier">joins</span>(:<span class="ruby-identifier">schools</span>).<span class="ruby-identifier">where</span>(:<span class="ruby-identifier">schools</span> =<span class="ruby-operator">&gt;</span> { :<span class="ruby-identifier">category</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'public'</span> })
<span class="ruby-constant">Student</span>.<span class="ruby-identifier">joins</span>(:<span class="ruby-identifier">schools</span>).<span class="ruby-identifier">where</span>(<span class="ruby-string">'schools.category'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'public'</span> )
</pre>

<h2 id="label-Overwriting+default+accessors">Overwriting default accessors</h2>

<p>All column values are automatically available through basic accessors on
the Active Record object, but sometimes you want to specialize this
behavior. This can be done by overwriting the default accessors (using the
same name as the attribute) and calling
<code>read_attribute(attr_name)</code> and <code>write_attribute(attr_name,
value)</code> to actually change things.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Song</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-comment"># Uses an integer of seconds to hold the length of the song</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier">length=</span>(<span class="ruby-identifier">minutes</span>)
    <span class="ruby-identifier">write_attribute</span>(:<span class="ruby-identifier">length</span>, <span class="ruby-identifier">minutes</span>.<span class="ruby-identifier">to_i</span> * <span class="ruby-value">60</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier">length</span>
    <span class="ruby-identifier">read_attribute</span>(:<span class="ruby-identifier">length</span>) <span class="ruby-operator">/</span> <span class="ruby-value">60</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>You can alternatively use <code>self[:attribute]=(value)</code> and
<code>self[:attribute]</code> instead of <code>write_attribute(:attribute,
value)</code> and <code>read_attribute(:attribute)</code>.</p>

<h2 id="label-Attribute+query+methods">Attribute query methods</h2>

<p>In addition to the basic accessors, query methods are also automatically
available on the Active Record object. Query methods allow you to test
whether an attribute value is present.</p>

<p>For example, an Active Record User with the <code>name</code> attribute has
a <code>name?</code> method that you can call to determine whether the user
has a name:</p>

<pre class="ruby"><span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;David&quot;</span>)
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name?</span> <span class="ruby-comment"># =&gt; true</span>

<span class="ruby-identifier">anonymous</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>)
<span class="ruby-identifier">anonymous</span>.<span class="ruby-identifier">name?</span> <span class="ruby-comment"># =&gt; false</span>
</pre>

<h2 id="label-Accessing+attributes+before+they+have+been+typecasted">Accessing attributes before they have been typecasted</h2>

<p>Sometimes you want to be able to read the raw attribute data without having
the column-determined typecast run its course first. That can be done by
using the <code>&lt;attribute&gt;_before_type_cast</code> accessors that
all attributes have. For example, if your Account model has a
<code>balance</code> attribute, you can call
<code>account.balance_before_type_cast</code> or
<code>account.id_before_type_cast</code>.</p>

<p>This is especially useful in validation situations where the user might
supply a string for an integer field and you want to display the original
string back in an error message. Accessing the attribute normally would
typecast the string to 0, which isn’t what you want.</p>

<h2 id="label-Dynamic+attribute-based+finders">Dynamic attribute-based finders</h2>

<p>Dynamic attribute-based finders are a cleaner way of getting (and/or
creating) objects by simple queries without turning to SQL. They work by
appending the name of an attribute to <code>find_by_</code>,
<code>find_last_by_</code>, or <code>find_all_by_</code> and thus produces
finders like <code>Person.find_by_user_name</code>,
<code>Person.find_all_by_last_name</code>, and
<code>Payment.find_by_transaction_id</code>. Instead of writing
<code>Person.where(:user_name =&gt; user_name).first</code>, you just do
<code>Person.find_by_user_name(user_name)</code>. And instead of writing
<code>Person.where(:last_name =&gt; last_name).all</code>, you just do
<code>Person.find_all_by_last_name(last_name)</code>.</p>

<p>It’s possible to add an exclamation point (!) on the end of the dynamic
finders to get them to raise an <code>ActiveRecord::RecordNotFound</code>
error if they do not return any records, like
<code>Person.find_by_last_name!</code>.</p>

<p>It’s also possible to use multiple attributes in the same find by
separating them with “<em>and</em>”.</p>

<pre class="ruby"><span class="ruby-constant">Person</span>.<span class="ruby-identifier">where</span>(:<span class="ruby-identifier">user_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">user_name</span>, :<span class="ruby-identifier">password</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">password</span>).<span class="ruby-identifier">first</span>
<span class="ruby-constant">Person</span>.<span class="ruby-identifier">find_by_user_name_and_password</span>(<span class="ruby-identifier">user_name</span>, <span class="ruby-identifier">password</span>) <span class="ruby-comment"># with dynamic finder</span>
</pre>

<p>It’s even possible to call these dynamic finder methods on relations and
named scopes.</p>

<pre>Payment.order(&quot;created_on&quot;).find_all_by_amount(50)
Payment.pending.find_last_by_amount(100)</pre>

<p>The same dynamic finder style can be used to create the object if it
doesn’t already exist. This dynamic finder is called with
<code>find_or_create_by_</code> and will return the object if it already
exists and otherwise creates it, then returns it. Protected attributes
won’t be set unless they are given in a block.</p>

<pre class="ruby"><span class="ruby-comment"># No 'Summer' tag exists</span>
<span class="ruby-constant">Tag</span>.<span class="ruby-identifier">find_or_create_by_name</span>(<span class="ruby-string">&quot;Summer&quot;</span>) <span class="ruby-comment"># equal to Tag.create(:name =&gt; &quot;Summer&quot;)</span>

<span class="ruby-comment"># Now the 'Summer' tag does exist</span>
<span class="ruby-constant">Tag</span>.<span class="ruby-identifier">find_or_create_by_name</span>(<span class="ruby-string">&quot;Summer&quot;</span>) <span class="ruby-comment"># equal to Tag.find_by_name(&quot;Summer&quot;)</span>

<span class="ruby-comment"># Now 'Bob' exist and is an 'admin'</span>
<span class="ruby-constant">User</span>.<span class="ruby-identifier">find_or_create_by_name</span>(<span class="ruby-string">'Bob'</span>, :<span class="ruby-identifier">age</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">40</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span> <span class="ruby-identifier">u</span>.<span class="ruby-identifier">admin</span> = <span class="ruby-keyword">true</span> }
</pre>

<p>Adding an exclamation point (!) on to the end of
<code>find_or_create_by_</code> will raise an
<code>ActiveRecord::RecordInvalid</code> error if the new record is
invalid.</p>

<p>Use the <code>find_or_initialize_by_</code> finder if you want to return a
new record without saving it first. Protected attributes won’t be set
unless they are given in a block.</p>

<pre># No 'Winter' tag exists
winter = Tag.find_or_initialize_by_name(&quot;Winter&quot;)
winter.persisted? # false</pre>

<p>To find by a subset of the attributes to be used for instantiating a new
object, pass a hash instead of a list of parameters.</p>

<pre class="ruby"><span class="ruby-constant">Tag</span>.<span class="ruby-identifier">find_or_create_by_name</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;rails&quot;</span>, :<span class="ruby-identifier">creator</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">current_user</span>)
</pre>

<p>That will either find an existing tag named “rails”, or create a new one
while setting the user that created it.</p>

<p>Just like <code>find_by_*</code>, you can also use <code>scoped_by_*</code>
to retrieve data. The good thing about using this feature is that the very
first time result is returned using <code>method_missing</code> technique
but after that the method is declared on the class. Henceforth
<code>method_missing</code> will not be hit.</p>

<pre>User.scoped_by_user_name('David')</pre>

<h2 id="label-Saving+arrays%2C+hashes%2C+and+other+non-mappable+objects+in+text+columns">Saving arrays, hashes, and other non-mappable objects in text columns</h2>

<p>Active Record can serialize any object in text columns using YAML. To do
so, you must specify this with a call to the class method
<code>serialize</code>. This makes it possible to store arrays, hashes, and
other non-mappable objects without doing any additional work.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">User</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-identifier">serialize</span> :<span class="ruby-identifier">preferences</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">create</span>(:<span class="ruby-identifier">preferences</span> =<span class="ruby-operator">&gt;</span> { <span class="ruby-string">&quot;background&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;black&quot;</span>, <span class="ruby-string">&quot;display&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">large</span> })
<span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span>).<span class="ruby-identifier">preferences</span> <span class="ruby-comment"># =&gt; { &quot;background&quot; =&gt; &quot;black&quot;, &quot;display&quot; =&gt; large }</span>
</pre>

<p>You can also specify a class option as the second parameter that’ll raise
an exception if a serialized object is retrieved as a descendant of a class
not in the hierarchy.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">User</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-identifier">serialize</span> :<span class="ruby-identifier">preferences</span>, <span class="ruby-constant">Hash</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">create</span>(:<span class="ruby-identifier">preferences</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">%w( one two three )</span>)
<span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span>).<span class="ruby-identifier">preferences</span>    <span class="ruby-comment"># raises SerializationTypeMismatch</span>
</pre>

<p>When you specify a class option, the default value for that attribute will
be a new instance of that class.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">User</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-identifier">serialize</span> :<span class="ruby-identifier">preferences</span>, <span class="ruby-constant">OpenStruct</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">preferences</span>.<span class="ruby-identifier">theme_color</span> = <span class="ruby-string">&quot;red&quot;</span>
</pre>

<h2 id="label-Single+table+inheritance">Single table inheritance</h2>

<p>Active Record allows inheritance by storing the name of the class in a
column that by default is named “type” (can be changed by overwriting
<code>Base.inheritance_column</code>). This means that an inheritance
looking like this:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Company</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">Firm</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Company</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">Client</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Company</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">PriorityClient</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Client</span>; <span class="ruby-keyword">end</span>
</pre>

<p>When you do <code>Firm.create(:name =&gt; &quot;37signals&quot;)</code>,
this record will be saved in the companies table with type = “Firm”. You
can then fetch this row again using <code>Company.where(:name =&gt;
'37signals').first</code> and it will return a Firm object.</p>

<p>If you don’t have a type column defined in your table, single-table
inheritance won’t be triggered. In that case, it’ll work just like normal
subclasses with no special magic for differentiating between them or
reloading the right type with find.</p>

<p>Note, all the attributes for all the cases are kept in the same table. Read
more: <a
href="http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html">www.martinfowler.com/eaaCatalog/singleTableInheritance.html</a></p>

<h2 id="label-Connection+to+multiple+databases+in+different+models">Connection to multiple databases in different models</h2>

<p>Connections are usually created through <a
href="Base.html#method-c-establish_connection">::establish_connection</a>
and retrieved by <a href="Base.html#method-i-connection">#connection</a>.
All classes inheriting from <a href="Base.html">ActiveRecord::Base</a> will
use this connection. But you can also set a class-specific connection. For
example, if Course is an <a href="Base.html">ActiveRecord::Base</a>, but
resides in a different database, you can just say
<code>Course.establish_connection</code> and Course and all of its
subclasses will use this connection instead.</p>

<p>This feature is implemented by keeping a connection pool in <a
href="Base.html">ActiveRecord::Base</a> that is a <a
href="../Hash.html">Hash</a> indexed by the class. If a connection is
requested, the <a
href="Base.html#method-c-retrieve_connection">::retrieve_connection</a>
method will go up the class-hierarchy until a connection is found in the
connection pool.</p>

<h2 id="label-Exceptions">Exceptions</h2>
<ul><li>
<p><a href="ActiveRecordError.html">ActiveRecordError</a> - Generic error
class and superclass of all other errors raised by Active Record.</p>
</li><li>
<p><a href="AdapterNotSpecified.html">AdapterNotSpecified</a> - The
configuration hash used in <code>establish_connection</code> didn't include
an <code>:adapter</code> key.</p>
</li><li>
<p><a href="AdapterNotFound.html">AdapterNotFound</a> - The
<code>:adapter</code> key used in <code>establish_connection</code>
specified a non-existent adapter (or a bad spelling of an existing one).</p>
</li><li>
<p><a href="AssociationTypeMismatch.html">AssociationTypeMismatch</a> - The
object assigned to the association wasn't of the type specified in the
association definition.</p>
</li><li>
<p><a href="SerializationTypeMismatch.html">SerializationTypeMismatch</a> -
The serialized object wasn't of the class specified as the second
parameter.</p>
</li><li>
<p>ConnectionNotEstablished+ - No connection has been established. Use
<code>establish_connection</code> before querying.</p>
</li><li>
<p><a href="RecordNotFound.html">RecordNotFound</a> - No record responded to
the <code>find</code> method. Either the row with the given ID doesn't
exist or the row didn't meet the additional restrictions. Some
<code>find</code> calls do not raise this exception to signal nothing was
found, please check its documentation for further details.</p>
</li><li>
<p><a href="StatementInvalid.html">StatementInvalid</a> - The database server
rejected the SQL statement. The precise error is added in the message.</p>
</li><li>
<p><a
href="MultiparameterAssignmentErrors.html">MultiparameterAssignmentErrors</a>
- Collection of errors that occurred during a mass assignment using the
<code>attributes=</code> method. The <code>errors</code> property of this
exception contains an array of <a
href="AttributeAssignmentError.html">AttributeAssignmentError</a> objects
that should be inspected to determine which attributes triggered the
errors.</p>
</li><li>
<p><a href="AttributeAssignmentError.html">AttributeAssignmentError</a> - An
error occurred while doing a mass assignment through the
<code>attributes=</code> method. You can inspect the <code>attribute</code>
property of the exception object to determine which attribute triggered the
error.</p>
</li></ul>

<p><strong>Note</strong>: The attributes listed are class-level attributes
(accessible from both the class and instance level). So it's possible to
assign a logger to the class through <code>Base.logger=</code> which will
then be used by all instances in the current object space.</p>

  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Class Methods</h3>

    
      <div id="method-c-3D-3D-3D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">===</span><span
            class="method-args">(object)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Overwrite the default class equality method to provide support for
association proxies.</p>
          

          
          <div class="method-source-code" id="3D-3D-3D-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 432</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">object</span>)
  <span class="ruby-identifier">object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- 3D-3D-3D-source -->
          
        </div>

        

        
      </div><!-- 3D-3D-3D-method -->

    
      <div id="method-c-arel_engine" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">arel_engine</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="arel_engine-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 440</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">arel_engine</span>
  <span class="ruby-ivar">@arel_engine</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
      <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">retrieve_connection_pool</span>(<span class="ruby-keyword">self</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">superclass</span>.<span class="ruby-identifier">arel_engine</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- arel_engine-source -->
          
        </div>

        

        
      </div><!-- arel_engine-method -->

    
      <div id="method-c-arel_table" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">arel_table</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="arel_table-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 436</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">arel_table</span>
  <span class="ruby-ivar">@arel_table</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Arel</span><span class="ruby-operator">::</span><span class="ruby-constant">Table</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">arel_engine</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- arel_table-source -->
          
        </div>

        

        
      </div><!-- arel_table-method -->

    
      <div id="method-c-clear_active_connections-21" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">clear_active_connections!</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="clear_active_connections-21-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 182</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">clear_active_connections!</span>
  <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">clear_active_connections!</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- clear_active_connections-21-source -->
          
        </div>

        

        
      </div><!-- clear_active_connections-21-method -->

    
      <div id="method-c-configurations" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">configurations</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Contains the database configuration - as is typically stored in
config/database.yml - as a <a href="../Hash.html">Hash</a>.</p>

<p>For example, the following database.yml…</p>

<pre>development:
  adapter: sqlite3
  database: db/development.sqlite3

production:
  adapter: sqlite3
  database: db/production.sqlite3</pre>

<p>…would result in <a
href="Base.html#method-c-configurations">::configurations</a> to look like
this:</p>

<pre class="ruby">{
   <span class="ruby-string">'development'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'adapter'</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'sqlite3'</span>,
      <span class="ruby-string">'database'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'db/development.sqlite3'</span>
   },
   <span class="ruby-string">'production'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'adapter'</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'sqlite3'</span>,
      <span class="ruby-string">'database'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'db/production.sqlite3'</span>
   }
}
</pre>
          

          
          <div class="method-source-code" id="configurations-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 368</span>
<span class="ruby-identifier">cattr_accessor</span> <span class="ruby-value">:configurations</span>, <span class="ruby-value">:instance_writer</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>
</pre>
          </div><!-- configurations-source -->
          
        </div>

        

        
      </div><!-- configurations-method -->

    
      <div id="method-c-connected-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connected?</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns true if Active Record is connected.</p>
          

          
          <div class="method-source-code" id="connected-3F-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 174</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connected?</span>
  <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">connected?</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- connected-3F-source -->
          
        </div>

        

        
      </div><!-- connected-3F-method -->

    
      <div id="method-c-connection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connection</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns the connection currently associated with the class. This can also
be used to “borrow” the connection to do database work unrelated to any of
the specific Active Records.</p>
          

          
          <div class="method-source-code" id="connection-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 143</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connection</span>
  <span class="ruby-identifier">retrieve_connection</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- connection-source -->
          
        </div>

        

        
      </div><!-- connection-method -->

    
      <div id="method-c-connection_config" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connection_config</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns the configuration of the associated connection as a hash:</p>

<pre class="ruby"><span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection_config</span>
<span class="ruby-comment"># =&gt; {:pool=&gt;5, :timeout=&gt;5000, :database=&gt;&quot;db/development.sqlite3&quot;, :adapter=&gt;&quot;sqlite3&quot;}</span>
</pre>

<p>Please use only for reading.</p>
          

          
          <div class="method-source-code" id="connection_config-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 161</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connection_config</span>
  <span class="ruby-identifier">connection_pool</span>.<span class="ruby-identifier">spec</span>.<span class="ruby-identifier">config</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- connection_config-source -->
          
        </div>

        

        
      </div><!-- connection_config-method -->

    
      <div id="method-c-connection_handler" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connection_handler</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>The connection handler</p>
          

          
          <div class="method-source-code" id="connection_handler-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 83</span>
<span class="ruby-identifier">class_attribute</span> <span class="ruby-value">:connection_handler</span>, <span class="ruby-value">:instance_writer</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>
</pre>
          </div><!-- connection_handler-source -->
          
        </div>

        

        
      </div><!-- connection_handler-method -->

    
      <div id="method-c-connection_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connection_id</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="connection_id-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 147</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connection_id</span>
  <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-string">'ActiveRecord::Base.connection_id'</span>]
<span class="ruby-keyword">end</span></pre>
          </div><!-- connection_id-source -->
          
        </div>

        

        
      </div><!-- connection_id-method -->

    
      <div id="method-c-connection_id-3D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connection_id=</span><span
            class="method-args">(connection_id)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="connection_id-3D-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 151</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connection_id=</span>(<span class="ruby-identifier">connection_id</span>)
  <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-string">'ActiveRecord::Base.connection_id'</span>] = <span class="ruby-identifier">connection_id</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- connection_id-3D-source -->
          
        </div>

        

        
      </div><!-- connection_id-3D-method -->

    
      <div id="method-c-connection_pool" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connection_pool</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="connection_pool-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 165</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connection_pool</span>
  <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">retrieve_connection_pool</span>(<span class="ruby-keyword">self</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ConnectionNotEstablished</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- connection_pool-source -->
          
        </div>

        

        
      </div><!-- connection_pool-method -->

    
      <div id="method-c-default_timezone" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">default_timezone</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Determines whether to use Time.local (using :local) or Time.utc (using
:utc) when pulling dates and times from the database. This is set to :local
by default.</p>
          

          
          <div class="method-source-code" id="default_timezone-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 375</span>
<span class="ruby-identifier">cattr_accessor</span> <span class="ruby-value">:default_timezone</span>, <span class="ruby-value">:instance_writer</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>
</pre>
          </div><!-- default_timezone-source -->
          
        </div>

        

        
      </div><!-- default_timezone-method -->

    
      <div id="method-c-establish_connection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">establish_connection</span><span
            class="method-args">(spec = ENV["DATABASE_URL"])</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Establishes the connection to the database. Accepts a hash as input where
the <code>:adapter</code> key must be specified with the name of a database
adapter (in lower-case) example for regular databases (MySQL, Postgresql,
etc):</p>

<pre class="ruby"><span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">establish_connection</span>(
  :<span class="ruby-identifier">adapter</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;mysql&quot;</span>,
  :<span class="ruby-identifier">host</span>     =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;localhost&quot;</span>,
  :<span class="ruby-identifier">username</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;myuser&quot;</span>,
  :<span class="ruby-identifier">password</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;mypass&quot;</span>,
  :<span class="ruby-identifier">database</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;somedatabase&quot;</span>
)
</pre>

<p>Example for SQLite database:</p>

<pre class="ruby"><span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">establish_connection</span>(
  :<span class="ruby-identifier">adapter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;sqlite&quot;</span>,
  :<span class="ruby-identifier">database</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;path/to/dbfile&quot;</span>
)
</pre>

<p>Also accepts keys as strings (for parsing from YAML for example):</p>

<pre class="ruby"><span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">establish_connection</span>(
  <span class="ruby-string">&quot;adapter&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;sqlite&quot;</span>,
  <span class="ruby-string">&quot;database&quot;</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;path/to/dbfile&quot;</span>
)
</pre>

<p>Or a URL:</p>

<pre>ActiveRecord::Base.establish_connection(
  &quot;postgres://myuser:mypass@localhost/somedatabase&quot;
)</pre>

<p>The exceptions <a href="AdapterNotSpecified.html">AdapterNotSpecified</a>,
<a href="AdapterNotFound.html">AdapterNotFound</a> and ArgumentError may be
returned on an error.</p>
          

          
          <div class="method-source-code" id="establish_connection-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 127</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">establish_connection</span>(<span class="ruby-identifier">spec</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;DATABASE_URL&quot;</span>])
  <span class="ruby-identifier">resolver</span> = <span class="ruby-constant">ConnectionSpecification</span><span class="ruby-operator">::</span><span class="ruby-constant">Resolver</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">spec</span>, <span class="ruby-identifier">configurations</span>
  <span class="ruby-identifier">spec</span> = <span class="ruby-identifier">resolver</span>.<span class="ruby-identifier">spec</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">spec</span>.<span class="ruby-identifier">adapter_method</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">AdapterNotFound</span>, <span class="ruby-node">&quot;database configuration specifies nonexistent #{spec.config[:adapter]} adapter&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">remove_connection</span>
  <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">establish_connection</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">spec</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- establish_connection-source -->
          
        </div>

        

        
      </div><!-- establish_connection-method -->

    
      <div id="method-c-generated_feature_methods" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">generated_feature_methods</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="generated_feature_methods-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 409</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generated_feature_methods</span>
  <span class="ruby-ivar">@generated_feature_methods</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">const_set</span>(<span class="ruby-value">:GeneratedFeatureMethods</span>, <span class="ruby-constant">Module</span>.<span class="ruby-identifier">new</span>)
    <span class="ruby-identifier">include</span> <span class="ruby-identifier">mod</span>
    <span class="ruby-identifier">mod</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- generated_feature_methods-source -->
          
        </div>

        

        
      </div><!-- generated_feature_methods-method -->

    
      <div id="method-c-inspect" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">inspect</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns a string like ‘Post(id:integer, title:string, body:text)’</p>
          

          
          <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 418</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">inspect</span>
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Base</span>
    <span class="ruby-keyword">super</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">abstract_class?</span>
    <span class="ruby-node">&quot;#{super}(abstract)&quot;</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">table_exists?</span>
    <span class="ruby-identifier">attr_list</span> = <span class="ruby-identifier">columns</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{c.name}: #{c.type}&quot;</span> } * <span class="ruby-string">', '</span>
    <span class="ruby-node">&quot;#{super}(#{attr_list})&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-node">&quot;#{super}(Table doesn't exist)&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- inspect-source -->
          
        </div>

        

        
      </div><!-- inspect-method -->

    
      <div id="method-c-logger" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">logger</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Accepts a logger conforming to the interface of Log4r or the default Ruby
1.8+ <a href="../Logger.html">Logger</a> class, which is then passed on to
any new database connections made and which can be retrieved on both a
class and instance level by calling <code>logger</code>.</p>
          

          
          <div class="method-source-code" id="logger-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 339</span>
<span class="ruby-identifier">cattr_accessor</span> <span class="ruby-value">:logger</span>, <span class="ruby-value">:instance_writer</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>
</pre>
          </div><!-- logger-source -->
          
        </div>

        

        
      </div><!-- logger-method -->

    
      <div id="method-c-mysql2_connection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">mysql2_connection</span><span
            class="method-args">(config)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Establishes a connection to the database that’s used by all Active Record
objects.</p>
          

          
          <div class="method-source-code" id="mysql2_connection-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/mysql2_adapter.rb, line 9</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">mysql2_connection</span>(<span class="ruby-identifier">config</span>)
  <span class="ruby-identifier">config</span>[<span class="ruby-value">:username</span>] = <span class="ruby-string">'root'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value">:username</span>].<span class="ruby-identifier">nil?</span>

  <span class="ruby-keyword">if</span> <span class="ruby-constant">Mysql2</span><span class="ruby-operator">::</span><span class="ruby-constant">Client</span>.<span class="ruby-identifier">const_defined?</span> <span class="ruby-value">:FOUND_ROWS</span>
    <span class="ruby-identifier">config</span>[<span class="ruby-value">:flags</span>] = <span class="ruby-constant">Mysql2</span><span class="ruby-operator">::</span><span class="ruby-constant">Client</span><span class="ruby-operator">::</span><span class="ruby-constant">FOUND_ROWS</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">client</span> = <span class="ruby-constant">Mysql2</span><span class="ruby-operator">::</span><span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">config</span>.<span class="ruby-identifier">symbolize_keys</span>)
  <span class="ruby-identifier">options</span> = [<span class="ruby-identifier">config</span>[<span class="ruby-value">:host</span>], <span class="ruby-identifier">config</span>[<span class="ruby-value">:username</span>], <span class="ruby-identifier">config</span>[<span class="ruby-value">:password</span>], <span class="ruby-identifier">config</span>[<span class="ruby-value">:database</span>], <span class="ruby-identifier">config</span>[<span class="ruby-value">:port</span>], <span class="ruby-identifier">config</span>[<span class="ruby-value">:socket</span>], <span class="ruby-value">0</span>]
  <span class="ruby-constant">ConnectionAdapters</span><span class="ruby-operator">::</span><span class="ruby-constant">Mysql2Adapter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client</span>, <span class="ruby-identifier">logger</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">config</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- mysql2_connection-source -->
          
        </div>

        

        
      </div><!-- mysql2_connection-method -->

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">(attributes = nil, options = {}) { |self| ... }</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>New objects can be instantiated as either empty (pass no construction
parameter) or pre-set with attributes but not yet saved (pass a hash with
key names matching the associated table column names). In both instances,
valid attribute keys are determined by the column names of the associated
table – hence you can’t have attributes that aren’t part of the table
columns.</p>

<p><code>initialize</code> respects mass-assignment security and accepts
either <code>:as</code> or <code>:without_protection</code> options in the
<code>options</code> parameter.</p>

<h4 id="method-c-new-label-Examples">Examples</h4>

<pre class="ruby"><span class="ruby-comment"># Instantiates a single new object</span>
<span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">first_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'Jamie'</span>)

<span class="ruby-comment"># Instantiates a single new object using the :admin mass-assignment security role</span>
<span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>({ :<span class="ruby-identifier">first_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'Jamie'</span>, :<span class="ruby-identifier">is_admin</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span> }, :<span class="ruby-identifier">as</span> =<span class="ruby-operator">&gt;</span> :<span class="ruby-identifier">admin</span>)

<span class="ruby-comment"># Instantiates a single new object bypassing mass-assignment security</span>
<span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>({ :<span class="ruby-identifier">first_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'Jamie'</span>, :<span class="ruby-identifier">is_admin</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span> }, :<span class="ruby-identifier">without_protection</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>)
</pre>
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 481</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">attributes</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">options</span> = {})
  <span class="ruby-ivar">@attributes</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">initialize_attributes</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">column_defaults</span>.<span class="ruby-identifier">dup</span>)
  <span class="ruby-ivar">@association_cache</span> = {}
  <span class="ruby-ivar">@aggregation_cache</span> = {}
  <span class="ruby-ivar">@attributes_cache</span> = {}
  <span class="ruby-ivar">@new_record</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-ivar">@readonly</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@destroyed</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@marked_for_destruction</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@previously_changed</span> = {}
  <span class="ruby-ivar">@changed_attributes</span> = {}
  <span class="ruby-ivar">@relation</span> = <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">ensure_proper_type</span>

  <span class="ruby-identifier">populate_with_current_scope_attributes</span>

  <span class="ruby-identifier">assign_attributes</span>(<span class="ruby-identifier">attributes</span>, <span class="ruby-identifier">options</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">attributes</span>

  <span class="ruby-keyword">yield</span> <span class="ruby-keyword">self</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">run_callbacks</span> <span class="ruby-value">:initialize</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- new-source -->
          
        </div>

        

        
      </div><!-- new-method -->

    
      <div id="method-c-remove_connection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">remove_connection</span><span
            class="method-args">(klass = self)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="remove_connection-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 178</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">remove_connection</span>(<span class="ruby-identifier">klass</span> = <span class="ruby-keyword">self</span>)
  <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">remove_connection</span>(<span class="ruby-identifier">klass</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- remove_connection-source -->
          
        </div>

        

        
      </div><!-- remove_connection-method -->

    
      <div id="method-c-retrieve_connection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">retrieve_connection</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="retrieve_connection-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 169</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">retrieve_connection</span>
  <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">retrieve_connection</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- retrieve_connection-source -->
          
        </div>

        

        
      </div><!-- retrieve_connection-method -->

    
      <div id="method-c-schema_format" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">schema_format</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Specifies the format to use when dumping the database schema with Rails’
Rakefile. If :sql, the schema is dumped as (potentially database- specific)
SQL statements. If :ruby, the schema is dumped as an <a
href="Schema.html">ActiveRecord::Schema</a> file which can be loaded into
any database that supports migrations. Use :ruby if you want to have
different database adapters for, e.g., your development and test
environments.</p>
          

          
          <div class="method-source-code" id="schema_format-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 386</span>
<span class="ruby-identifier">cattr_accessor</span> <span class="ruby-value">:schema_format</span> , <span class="ruby-value">:instance_writer</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>
</pre>
          </div><!-- schema_format-source -->
          
        </div>

        

        
      </div><!-- schema_format-method -->

    
      <div id="method-c-timestamped_migrations" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">timestamped_migrations</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Specify whether or not to use timestamps for migration versions</p>
          

          
          <div class="method-source-code" id="timestamped_migrations-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 392</span>
<span class="ruby-identifier">cattr_accessor</span> <span class="ruby-value">:timestamped_migrations</span> , <span class="ruby-value">:instance_writer</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>
</pre>
          </div><!-- timestamped_migrations-source -->
          
        </div>

        

        
      </div><!-- timestamped_migrations-method -->

    
    </section><!-- public-class-method-details -->
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-3C-3D-3E" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">&lt;=&gt;</span><span
            class="method-args">(other_object)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Allows sort on objects</p>
          

          
          <div class="method-source-code" id="3C-3D-3E-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 619</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">&lt;=&gt;</span>(<span class="ruby-identifier">other_object</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">other_object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">to_key</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">other_object</span>.<span class="ruby-identifier">to_key</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- 3C-3D-3E-source -->
          
        </div>

        

        
      </div><!-- 3C-3D-3E-method -->

    
      <div id="method-i-3D-3D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">==</span><span
            class="method-args">(comparison_object)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns true if <code>comparison_object</code> is the same exact object, or
<code>comparison_object</code> is of the same type and <code>self</code>
has an ID and it is equal to <code>comparison_object.id</code>.</p>

<p>Note that new records are different from any other record by definition,
unless the other record is the receiver itself. Besides, if you fetch
existing records with <code>select</code> and leave the ID out, you’re on
your own, this predicate will return false.</p>

<p>Note also that destroying a record preserves its ID in the model instance,
so deleted models are still comparable.</p>
          

          
          <div class="method-source-code" id="3D-3D-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 594</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">comparison_object</span>)
  <span class="ruby-keyword">super</span> <span class="ruby-operator">||</span>
    <span class="ruby-identifier">comparison_object</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>) <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">id</span>.<span class="ruby-identifier">present?</span> <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">comparison_object</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- 3D-3D-source -->
          
        </div>

        
        <div class="aliases">
          Also aliased as: <a href="Base.html#method-i-eql-3F">eql?</a>
        </div>
        

        
      </div><!-- 3D-3D-method -->

    
      <div id="method-i-connection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">connection</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns the connection currently associated with the class. This can also
be used to “borrow” the connection to do database work that isn’t easily
done without going straight to SQL.</p>
          

          
          <div class="method-source-code" id="connection-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_specification.rb, line 89</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connection</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">connection</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- connection-source -->
          
        </div>

        

        
      </div><!-- connection-method -->

    
      <div id="method-i-encode_with" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">encode_with</span><span
            class="method-args">(coder)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Populate <code>coder</code> with attributes about this record that should
be serialized. The structure of <code>coder</code> defined in this method
is guaranteed to match the structure of <code>coder</code> passed to the
<code>init_with</code> method.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Post</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">coder</span> = {}
<span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">encode_with</span>(<span class="ruby-identifier">coder</span>)
<span class="ruby-identifier">coder</span> <span class="ruby-comment"># =&gt; { 'id' =&gt; nil, ... }</span>
</pre>
          

          
          <div class="method-source-code" id="encode_with-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 581</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">encode_with</span>(<span class="ruby-identifier">coder</span>)
  <span class="ruby-identifier">coder</span>[<span class="ruby-string">'attributes'</span>] = <span class="ruby-identifier">attributes</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- encode_with-source -->
          
        </div>

        

        
      </div><!-- encode_with-method -->

    
      <div id="method-i-eql-3F" class="method-detail method-alias">
        
        <div class="method-heading">
          <span class="method-name">eql?</span><span
            class="method-args">(comparison_object)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
        </div>

        

        
        <div class="aliases">
          Alias for: <a href="Base.html#method-i-3D-3D">==</a>
        </div>
        
      </div><!-- eql-3F-method -->

    
      <div id="method-i-freeze" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">freeze</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Freeze the attributes hash such that associations are still accessible,
even on destroyed records.</p>
          

          
          <div class="method-source-code" id="freeze-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 609</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">freeze</span>
  <span class="ruby-ivar">@attributes</span>.<span class="ruby-identifier">freeze</span>; <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- freeze-source -->
          
        </div>

        

        
      </div><!-- freeze-method -->

    
      <div id="method-i-frozen-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">frozen?</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if the attributes hash has been frozen.</p>
          

          
          <div class="method-source-code" id="frozen-3F-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 614</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">frozen?</span>
  <span class="ruby-ivar">@attributes</span>.<span class="ruby-identifier">frozen?</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- frozen-3F-source -->
          
        </div>

        

        
      </div><!-- frozen-3F-method -->

    
      <div id="method-i-hash" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">hash</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Delegates to id in order to allow two records of the same type and id to
work with something like:</p>

<pre class="ruby">[ <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">1</span>), <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">2</span>), <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">3</span>) ] &amp; [ <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">1</span>), <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">4</span>) ] <span class="ruby-comment"># =&gt; [ Person.find(1) ]</span>
</pre>
          

          
          <div class="method-source-code" id="hash-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 604</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">hash</span>
  <span class="ruby-identifier">id</span>.<span class="ruby-identifier">hash</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- hash-source -->
          
        </div>

        

        
      </div><!-- hash-method -->

    
      <div id="method-i-init_with" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">init_with</span><span
            class="method-args">(coder)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Initialize an empty model object from <code>coder</code>.
<code>coder</code> must contain the attributes necessary for initializing
an empty model object. For example:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Post</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">post</span> = <span class="ruby-constant">Post</span>.<span class="ruby-identifier">allocate</span>
<span class="ruby-identifier">post</span>.<span class="ruby-identifier">init_with</span>(<span class="ruby-string">'attributes'</span> =<span class="ruby-operator">&gt;</span> { <span class="ruby-string">'title'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'hello world'</span> })
<span class="ruby-identifier">post</span>.<span class="ruby-identifier">title</span> <span class="ruby-comment"># =&gt; 'hello world'</span>
</pre>
          

          
          <div class="method-source-code" id="init_with-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 514</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">init_with</span>(<span class="ruby-identifier">coder</span>)
  <span class="ruby-ivar">@attributes</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">initialize_attributes</span>(<span class="ruby-identifier">coder</span>[<span class="ruby-string">'attributes'</span>])
  <span class="ruby-ivar">@relation</span> = <span class="ruby-keyword">nil</span>

  <span class="ruby-ivar">@attributes_cache</span>, <span class="ruby-ivar">@previously_changed</span>, <span class="ruby-ivar">@changed_attributes</span> = {}, {}, {}
  <span class="ruby-ivar">@association_cache</span> = {}
  <span class="ruby-ivar">@aggregation_cache</span> = {}
  <span class="ruby-ivar">@readonly</span> = <span class="ruby-ivar">@destroyed</span> = <span class="ruby-ivar">@marked_for_destruction</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@new_record</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">run_callbacks</span> <span class="ruby-value">:find</span>
  <span class="ruby-identifier">run_callbacks</span> <span class="ruby-value">:initialize</span>

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- init_with-source -->
          
        </div>

        

        
      </div><!-- init_with-method -->

    
      <div id="method-i-initialize_dup" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">initialize_dup</span><span
            class="method-args">(other)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Duped objects have no id assigned and are treated as new records. Note that
this is a “shallow” copy as it copies the object’s attributes only, not its
associations. The extent of a “deep” copy is application specific and is
therefore left to the application to implement according to its need. The
dup method does not preserve the timestamps (created|updated)_(at|on).</p>
          

          
          <div class="method-source-code" id="initialize_dup-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 535</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize_dup</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-identifier">cloned_attributes</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">clone_attributes</span>(<span class="ruby-value">:read_attribute_before_type_cast</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">initialize_attributes</span>(<span class="ruby-identifier">cloned_attributes</span>, <span class="ruby-value">:serialized</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>)

  <span class="ruby-identifier">cloned_attributes</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">primary_key</span>)

  <span class="ruby-ivar">@attributes</span> = <span class="ruby-identifier">cloned_attributes</span>

  <span class="ruby-identifier">_run_after_initialize_callbacks</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:_run_after_initialize_callbacks</span>)

  <span class="ruby-ivar">@changed_attributes</span> = {}
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">column_defaults</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attr</span>, <span class="ruby-identifier">orig_value</span><span class="ruby-operator">|</span>
    <span class="ruby-ivar">@changed_attributes</span>[<span class="ruby-identifier">attr</span>] = <span class="ruby-identifier">orig_value</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">field_changed?</span>(<span class="ruby-identifier">attr</span>, <span class="ruby-identifier">orig_value</span>, <span class="ruby-ivar">@attributes</span>[<span class="ruby-identifier">attr</span>])
  <span class="ruby-keyword">end</span>

  <span class="ruby-ivar">@aggregation_cache</span> = {}
  <span class="ruby-ivar">@association_cache</span> = {}
  <span class="ruby-ivar">@attributes_cache</span> = {}
  <span class="ruby-ivar">@new_record</span>  = <span class="ruby-keyword">true</span>

  <span class="ruby-identifier">ensure_proper_type</span>
  <span class="ruby-identifier">populate_with_current_scope_attributes</span>
  <span class="ruby-keyword">super</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- initialize_dup-source -->
          
        </div>

        

        
      </div><!-- initialize_dup-method -->

    
      <div id="method-i-inspect" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">inspect</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns the contents of the record as a nicely formatted string.</p>
          

          
          <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 639</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">inspect</span>
  <span class="ruby-identifier">inspection</span> = <span class="ruby-keyword">if</span> <span class="ruby-ivar">@attributes</span>
                 <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">column_names</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
                   <span class="ruby-keyword">if</span> <span class="ruby-identifier">has_attribute?</span>(<span class="ruby-identifier">name</span>)
                     <span class="ruby-node">&quot;#{name}: #{attribute_for_inspect(name)}&quot;</span>
                   <span class="ruby-keyword">end</span>
                 }.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;, &quot;</span>)
               <span class="ruby-keyword">else</span>
                 <span class="ruby-string">&quot;not initialized&quot;</span>
               <span class="ruby-keyword">end</span>
  <span class="ruby-node">&quot;#&lt;#{self.class} #{inspection}&gt;&quot;</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- inspect-source -->
          
        </div>

        

        
      </div><!-- inspect-method -->

    
      <div id="method-i-readonly-21" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">readonly!</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Marks this record as read only.</p>
          

          
          <div class="method-source-code" id="readonly-21-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 634</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">readonly!</span>
  <span class="ruby-ivar">@readonly</span> = <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- readonly-21-source -->
          
        </div>

        

        
      </div><!-- readonly-21-method -->

    
      <div id="method-i-readonly-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">readonly?</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if the record is read only. Records loaded
through joins with piggy-back attributes will be marked as read only since
they cannot be saved.</p>
          

          
          <div class="method-source-code" id="readonly-3F-source">
            <pre><span class="ruby-comment"># File /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/base.rb, line 629</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">readonly?</span>
  <span class="ruby-ivar">@readonly</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- readonly-3F-source -->
          
        </div>

        

        
      </div><!-- readonly-3F-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

